Last post Apr 28, 2012 03:25 AM by hans_v
Apr 28, 2012 12:41 AM|fuzzy_boy001|LINK
i have a tblmsges, it has foreign keys senderID and RecieverID, both are foreign keys from tblUser..
now i wana aply a join query which gives me sender and reciever name,, both at a time..... how can i do it???
Apr 28, 2012 03:25 AM|hans_v|LINK
INNER JOIN tblUser AS Sender ON Sender.UserID = tblmsges.SenderID
INNER JOIN tblUser AS Reciever ON Reciever.UserID = tblmsges.RecieverID
Instead of joins, you can use subquerys as well
SELECT (SELECT Name FROM tblUser WHERE UserID = SenderID) AS Sender
,(SELECT Name FROM tblUser WHERE UserID = RecieverID) AS Reciever