I'm trying to get data from 2 tables with one SQL statement using joins. The idea is quite simple. A project has participants, and in a project overview I want to show the project info with the amount of participants.
Right now there are 2 projects, one project with participants and the other project without participants.
I use this query:
SELECT SQL_CALC_FOUND_ROWS `p`.`id`,
`p`.`title`,
`p`.`live`,
`p`.`startDate`,
`p`.`endDate`,
COUNT(`part`.`id`) AS `participants`
FROM `projects` `p`
LEFT OUTER JOIN `participants` `part`
ON `p`.`id` = `part`.`projectid`
ORDER BY `p`.`live` DESC,
`p`.`startDate` DESC
LIMIT 0,10
Problem is, this query only returns the project with participants and the one without participants is left out.
What am I doing wrong here?