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
精彩评论