Guest Posted May 5, 2011 Share Posted May 5, 2011 How could I do something like this? $sql = "SELECT post_text from posts WHERE poster_id = users.userid"; Link to comment https://forums.phpfreaks.com/topic/235645-need-to-select-from-another-table/ Share on other sites More sharing options...
requinix Posted May 5, 2011 Share Posted May 5, 2011 Use a JOIN. SELECT users.whateveryouwant, posts.post_text FROM posts JOIN users ON posts.poster_id = users.userid Link to comment https://forums.phpfreaks.com/topic/235645-need-to-select-from-another-table/#findComment-1211148 Share on other sites More sharing options...
fugix Posted May 5, 2011 Share Posted May 5, 2011 yep, if the fields from different tables match, use left or right join, otherwise use full join Link to comment https://forums.phpfreaks.com/topic/235645-need-to-select-from-another-table/#findComment-1211150 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.