开发者

Finding the 20 most commented 20 news

开发者 https://www.devze.com 2023-01-03 02:52 出处:网络
I need to find a function. the scenario is : I have 2 table. 1. news table 2. news_comment table need to find the most commented 20 news.

I need to find a function. the scenario is : I have 2 table. 1. news table 2. news_comment table

need to find the most commented 20 news. the news_comment table has the r开发者_StackOverflowelationship with the news table

Thank you


try the give query. it may help.

Top 20 give first 20, join lin 2 tables count(news_comment.id) give no of comment

select top 20 news.*, count(news_comment.id) as no_of_comment from news inner join news_comment on news.id = news_comment.newsid order by no_of_comment desc
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号