To get the rows in Photos where there are at least five per PostID...
select PostID, count(PostID) as occurances from Photos group by PostID
To get only those where there are at least five...
select PostID from (select PostID, count(PostID) as occurances from Photos group by PostID) p where occurances >= 5
To get the blog posts that correspond...
select * from BlogPosts where ID in (select PostID from (select PostID, count(PostID) as occurances from Photos group by PostID) p where occurances >= 5);
Or, really - you should first create a view that only returns the PostIDs from Photos that have more than five occurances:
create view atLeastFive as select PostID from (select PostID, count(PostID) as occurances from Photos group by PostID) p where occurances >= 5
Then your query looks a little more presentable:
select * from BlogPosts where ID in (select PostID from atLeastFive)
Make sure that your Photos table has an index on PostID or the performance will end up suffering.