What I have below works good and returns all the reviews depending on the venue_id selected.
SELECT comments,
DATE_FORMAT(review_date, '%M %D %Y') AS subdir,
publisher, rating, FROM tbl_reviews WHERE venue_id='"...
Example return
comments: some comments about the venue
date: 12th dec 12
rating: 4
comments: some comments about the venue
date: 13th dec 12
rating: 2
and so on…
But now I need to COUNT the number of reviews for that particular venue_id.
SELECT comments,
DATE_FORMAT(review_date, '%M %D %Y') AS subdir,
publisher, rating, COUNT(venue_id) AS VenueReviewTotal FROM tbl_reviews WHERE venue_id='"...
Example return
comments: some comments about the venue
date: 12th dec 12
rating: 4
and stops, only shows one review even if there are 15
The review count is correct
VenueReviewTotal 15
What is happening, why does this happen when I introduce the COUNT function?
the technical answer: you forgot the GROUP BY clause
the let’s-rethink-this answer: if you’re displaying all the reviews for a given venue, why do you need to count them at the same time? can’t you do that with your application language as you’re printing the reviews?
alternatively, do you just want the count and not the individual reviews?