Kryptix Posted May 27, 2010 Share Posted May 27, 2010 Not really sure how to do this. Say for example you have a table with columns `sender` and `receiver` which are their ID from the users table. I need to do something like... SELECT `username` AS 'sender' FROM `messages` JOIN `users` ON `messages`.`sender` = `users`.`id` But how would I also obtain the receiver within the same query? Quote Link to comment https://forums.phpfreaks.com/topic/203038-multiple-joins-from-the-same-table/ Share on other sites More sharing options...
Kryptix Posted May 27, 2010 Author Share Posted May 27, 2010 Solved: SELECT `a`.`username` AS 'sender', `b`.`username` AS `receiver` FROM `messages` JOIN `users` a ON `messages`.`sender` = `a`.`id` JOIN `users` b ON `messages`.`receiver` = `b`.`id` Quote Link to comment https://forums.phpfreaks.com/topic/203038-multiple-joins-from-the-same-table/#findComment-1063940 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.