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? Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.