Id number news
The content of news content
The title of news headline
2, review table, the comment
Comment id number
The content review
NewsId news number
Requirements:
Using MySQL query to comment on the largest number of 10 news
CodePudding user response:
Select top 10 Anderson d, a.c ontent, a.t itle, b.com _qty from news a, (select count (1) as com_qty, comment. NewsId from the comment group by the comment. NewsId) b where a.n ewsId=b.n ewsId order by b.com _qty descCodePudding user response:
I can't, error, and, within a b.com _qty! What's the meaning ofCodePudding user response:
Select *The from
(select Anderson d, count (b.i d) as comment_cnt
The from
News as a
Inner join
The comment as b on Anderson, d=b.n ewsId
) as a
The order by comment_cnt desc
Limit 10
So try
CodePudding user response: