MYSQL Query with 2 columns in Table A related to 1 column in Table B
Posted
by
CYREX
on Stack Overflow
See other posts from Stack Overflow
or by CYREX
Published on 2011-02-20T23:13:13Z
Indexed on
2011/02/20
23:25 UTC
Read the original article
Hit count: 222
mysql
I have 2 Tables, User and Mail.
In User Table i have 2 columns that i will use, the ID column which makes the relation with the Mail Table and it is the Index of User Table and the Name column.
In Mail Table i have Receiver Column and Sender Column. Both columns, Receiver and Sender have a number that relates to the ID Column in the User Table. In the User Table is where the name columns resides and i want to make a query that shows me the Receiver and Sender Columns but with the name of the user, not the ID.
Up to this point i have this:
SELECT name AS Send, name AS Receive FROM mail,user WHERE sender=guid;
I know there is still a part of the query missing but i can not figure out what else to put to tell it to show in the SEND output column the name of the sender and in the RECEIVE output column the name of the receiver.
© Stack Overflow or respective owner