Web Hosting Talk







View Full Version : SQL query to search by last posted topic


ilyash
03-11-2005, 09:17 PM
What is the SQL query to search for the hottest threads.

Like if i post in thread #3 from the bottom, it becomes thread #1

Is this more than one query?

Like select threadid from [most recent reply]

Select * from threads where threadid=[threadid up there];

and

Select * from threads where threadid != [threadid up there];

but then the second hottest.. etc? how would that work?

hiryuu
03-12-2005, 12:25 AM
You can use ORDER BY and LIMIT to pull as many rows as you need. Determining the most recently updated thread (as opposed to recently started) will probably need a join and a grouping. Most forums already have scripting for this, or at least available add-ons.

datutorials
03-12-2005, 06:42 PM
For what forum do you want to make the query ?

ilyash
03-13-2005, 12:12 AM
I wrote my own..

So I guess I am going to select from replies.. order by date..

and then for those threadids, i can get threads in that order.