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? 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` 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
Archived
This topic is now archived and is closed to further replies.