SQL查询问题

时间:2014-08-05 07:20:24

标签: mysql sql

大家好,基本上我试图做的就是这个......

我写了这个查询..

SELECT * from comments where author = (select min(author ) from comments )

这是结果..

http://gyazo.com/87b7e11fd0b7acf9d4b7840ab67a36f1

但我不确定此查询是否正确

谢谢!

3 个答案:

答案 0 :(得分:0)

为什么你不试这个:

SELECT *,COUNT(*) nr_coments
FROM comments 
GROUP BY author 
ORDER BY nr_coments DESC
LIMIT 1

答案 1 :(得分:0)

试试这个:

select username, first name, last name, count( username) from comments 
group by username, first name, last name
order by count(username)

这可能会有所帮助......

答案 2 :(得分:0)

试试这个,

SELECT
   Author,
   count(Comment)
FROM 
   table_name 
GROUP BY author 
ORDER BY 
   count(comment) 
DESC LIMIT 1;