我有这样的表。但它似乎MySQL不计算我目前的第二次连接。我想知道我错过了我的评论列表的报告流程数。sql多个加入和计数
,我想拥有率平均也算报告
SELECT *, avg(rate.score), count(report.id) FROM `comment`
left join rate on (comment.id = rate.comment_id)
left join report on (comment.id = report.comment_id)
group by comment.id
id text id comment_id score id comment_id type avg(rate.score) count(report.comment_id)
1 good article 1 1 2 1 1 1 4.0000 20
2 bad article NULL NULL NULL NULL NULL NULL NULL 0
好文章有报告。
count(report.id)
给我错误的值。我的错误是什么?
我看到'计数(report.id)',这是一个错字吗? – 2012-07-12 13:42:14