[thelist] Selecting most active n blogs [php/mysql]
rudy
r937 at interlog.com
Fri Apr 12 15:44:00 CDT 2002
>select all blogs and coments
>order by comments limit to 5
select blogEntry.foo, blogEntry.bar, count(*) as Comments
from blogEntry, blogComments
where blogEntry.ID=blogComments.EntryID
group by blogEntry.foo, blogEntry.bar
order by CommentCount desc limit 5
in the join, select no fields from the blogComments table
the GROUP BY should list all the non-aggregate fields in the SELECT
rudy
More information about the thelist
mailing list