peter_anderson Posted July 3, 2010 Share Posted July 3, 2010 Hi, I want to list the latest topics in the category, but order them by the one with the latest posts. Here is the queries I use currently (which orders them by ID) $query = 'SELECT * from `topics` WHERE `category` = ' . $catid . ' AND `sticky` = 0 ORDER by `id` DESC '.$limit.''; // this one is within a loop for the results of the above $query = 'SELECT * from `posts` WHERE `topic` = ' . $row['id']; Is there any way I can join these queries, so it sorts DESC by the id in the posts column? Link to comment https://forums.phpfreaks.com/topic/206657-order-by-result-from-another-query/ Share on other sites More sharing options...
Mchl Posted July 3, 2010 Share Posted July 3, 2010 Possibly. If there's a foreign key in `posts` pointing to `topics` Link to comment https://forums.phpfreaks.com/topic/206657-order-by-result-from-another-query/#findComment-1080869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.