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? Quote 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` Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.