mysql语句的写法

表message结构如下:

id:文章id
title:标题
content:内容
hits:点击率

表comment结构如下:

cid:留言id
mid:对应message文章id
ccon:留言内容

现在通过查询数据库得到下面结果(并按照回复数量排序,回复数量最多的在前面)。

结果如下:

[b]文章id 文章标题 文章点击率 文章回复数量[/b]

用一条sql语句完成上面查询,如果文章没有回复则回复数量为0

select id, title, hits, count(mid) from message left join comm on message.id=comm.mid(+) group by id, title, hits;

select id,title, hits,a.chits from message left join (select mid,count(mid) as chits from comment grounp by mid) a
on id=a.mid
试一下,没有测 不好意思