[thelist] Selecting most active n blogs [php/mysql]
Anthony Baratta
Anthony at Baratta.com
Fri Apr 12 14:13:01 CDT 2002
At 11:41 AM 4/12/2002, Martin Kuplens-Ewart wrote:
>Select all blogs
>For each, grab number of comments [from separate table]
>Then evaluate number of comments, rejigging position in results, until 5
>with most comments have been found.
>
>Is there a faster way of doing this?
I'm not the SQL Wizard, but this is how I would approach it:
Select Top 5 Count(CommentID)
From CommentTable
Group By BlogID
Order By Count(CommentID)
Top is a MS SQL function. mySQL has Limit, but I don't remember where it goes.
---
Anthony Baratta
President
Keyboard Jockeys
"Conformity is the refuge of the unimaginative."
More information about the thelist
mailing list