Jump to content

Order by result from another query


peter_anderson

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.