-4

我需要一些帮助才能获得评论最多的帖子。有 2 个表,一个有帖子 web_content,另一个表有评论 web_jcomments。

我需要获得评论最多的帖子和评论的数量。web_content.ID = web_jcomments.object_id。数据库在 MYSQL 中。

请问有人可以帮助SQL代码吗?感谢您阅读

4

2 回答 2

1
SELECT 
       wc.ID,
       wj.Total
FROM web_content as wc
LEFT JOIN (
          SELECT 
                object_id,
                count(object_id)   as Total 
) as  wj on wc.ID = wj.object_id
ORDER BY wi.Total DESC
于 2013-01-08T13:50:45.763 回答
0

很久没写MySQL了。。

就像是:

SELECT  
        web_content.ID, 
        COUNT(*) 
FROM web_content.ID 
LEFT JOIN web_jcomments ON (web_content.ID = web_jcomments.object_id)
于 2013-01-08T13:47:49.577 回答