I have three tables
Post
ID Name
1 \'Something\'
2 \'Something else\'
3 \'One more\'
Comment
ID PostId Profile
From the definition of the COUNT function:
The COUNT function will only count those records in which the field in the brackets is NOT NULL.
This means that simple outer join like this would work:
SELECT Post.ID, COUNT(Comment.ID)
FROM Post LEFT JOIN Comment ON (Post.ID = Comment.PostId)
LEFT JOIN Profile ON (Profile.ID = Comment.ProfileID AND
Profile.Approved = 1)
GROUP BY Post.ID