0
테이블을 각 부서의 제목과 수를 반환해야합니다는 MySQL의에서
departments: id, title
comments: id, year_code
department_comments: comment_id, department_id
가 나는 그것이 얼마나 많은 의견의 수와, 모든 부서의 제목을 나열합니다.
select
d.title, count(c.id) as total_comments
from
departments d, comments c
left join
department_comments dc on c.id = dc.comment_id
where
c.year_code = 1011
위의 쿼리의 라인을 따라
뭔가가 작동하지 않습니다,하지만 당신에게 내가 달성하기 위해 노력하고 있습니다 무엇의 아이디어를 줄 것이다.
d.title (count(c.id))
---------------------
Maintenance (10)
Finance (5)
Security (13)