ari_aaron Posted February 24, 2008 Share Posted February 24, 2008 I have a user table like this: UID | Username 2 theuser 5 ari_aaron 3 me 4 blah and another table like this: Giver | Receiver | Comments 2 5 hi! 4 3 test 2 4 ... I am using this SQL: SELECT users.username AS give_name, tans.* FROM users INNER JOIN trans ON trans.receiver=users.UID In order to show usernames instead of UIDs. How can I get this to work for both giver and receiver? Link to comment https://forums.phpfreaks.com/topic/92751-doubble-join/ Share on other sites More sharing options...
php_dave Posted February 24, 2008 Share Posted February 24, 2008 Hi, This works - but maybe not the tidiest! SELECT use_give.Username AS Giver_Name, users.Username AS Receiver_Name, trans.Comments FROM trans Inner Join users ON trans.Receiver = users.uid Inner Join users AS use_give ON trans.Giver = use_give.uid HTH Dave Link to comment https://forums.phpfreaks.com/topic/92751-doubble-join/#findComment-475199 Share on other sites More sharing options...
fenway Posted February 25, 2008 Share Posted February 25, 2008 actually that's the only way. well, the most logical without subqueries. Link to comment https://forums.phpfreaks.com/topic/92751-doubble-join/#findComment-475570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.