How to JOIN a COUNT from a table, and then effect that COUNT with another JOIN
- by jakenoble
Hi
I have three tables
Post
ID Name
1 'Something'
2 'Something else'
3 'One more'
Comment
ID PostId ProfileID Comment
1 1 1 'Hi my name is'
2 2 2 'I like cakes'
3 3 3 'I hate cakes'
Profile
ID Approved
1 1
2 0
3 1
I want to count the comments for a post where the profile for the comment is approved
I can select the data from Post and then join a count from Comment fine. But this count should be dependent on if the Profile is approved or not.
The results I am expecting is
CommentCount
PostId Count
1 1
2 0
3 1
Thanks for any help.