I'm trying to find the id of the players whose name is 'Jack' and the number of games they have played:
Select p.id, count(*) as numOfGamePlayed
from player p, game g
where p.name = 'Jack' and p.id = g.id
group by p.id;
The problem is, this will only list the players name Jack who have played at least one game. How can I also list those who have not played any games?
Edit: for those player, the numOfGamePlayed must be 0. If I do this
Select p.id, count(*) as numOfGamePlayed
from player p LEFT JOIN game g ON p.id = g.id
where p.name = 'Jack'
group by p.id;
those who have not played any games will still have numOfGamePlayed displayed as 1