哦?好像误解了你的意思了!
是不是把帖子回复数在前5名的所有回复查出来啊?试试看:
select t1.tid,t1.subject from table1 as t1,
(
select tid from (select tid,count(1) as count from table1 group by tid) as t order by count desc limit 5
) as t2
where t1.tid=t2.tid
之前的只能查前5条,可能tid数量不到5个
select t1.tid,t1.subject from table1 as t1
left join (select tid,count(1) as count from table1 group by tid) as t2 on t1.tid=t2.tid order by t2.count desc limit 0,5;
mysql 需要开启子查询
select tid,subject from 表 where tid in (
select tid from (
select tid,count(*) as C from 表 group by tid
)T
order by tid desc
) limit 0,5
select t1.tid,t1.subject
from 表 t1,(select tid,count(*) as group_num from 表 group by tid) t2
where t1.tid=t2.tid
order by t2.group_num desc
limit 5;