I am counting the results of a table I LEFT JOINED:
SELECT p.*,COUNT(po.name) AS posts
FROM projects p
left join posts po on p.name = po.name
group by p.id
http://sqlfiddle.com/#!9/3e9d4b/4
But now I want to add another table via LEFT JOIN and count it also:
SELECT p.*,COUNT(po.name) AS posts,
COUNT(ta.name) AS tasks
FROM projects p
left join posts po on p.name = po.name
left join tasks ta on p.name = ta.name
group by p.id
http://sqlfiddle.com/#!9/ee068/2
But now the counting is wrong. For cat I have only 2 posts and 3 tasks. Where is the number 6 coming from?