V Posted July 10, 2010 Share Posted July 10, 2010 Is it possible to echo out data from 2 tables but without making 2 loops and queries? The code I use now is $sql = "SELECT * FROM posts ORDER BY post_id DESC"; Can I combine it with.. $sql = "SELECT * FROM categories ORDER BY cat_id DESC"; ..and define vars for both in one "while" loop? Link to comment https://forums.phpfreaks.com/topic/207312-select-from-more-tables/ Share on other sites More sharing options...
robert_gsfame Posted July 10, 2010 Share Posted July 10, 2010 Sure you can, use JOIN for example: SELECT table1.*,table2.* FROM table1 JOIN table2 ON table1.username=table2.username WHERE blabla then get the array result Link to comment https://forums.phpfreaks.com/topic/207312-select-from-more-tables/#findComment-1083995 Share on other sites More sharing options...
V Posted July 10, 2010 Author Share Posted July 10, 2010 Very cool! That's much better than what I used to do THanks! Link to comment https://forums.phpfreaks.com/topic/207312-select-from-more-tables/#findComment-1084191 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.