在MySQL数据库表注释中有超过20亿条记录,从这个表中我必须获取具有最大注释数的post_id
:
select post_id,Count(id) as total from comments group by post_id
但是这给了我所有现有的帖子ID,而不是上述查询的评论。我只想要帖子ID最多没有评论
答案 0 :(得分:1)
select post_id, Count(id) as total
from comments
group by post_id
order by total desc
limit 1