Reputation: 12598
I have a SQL table which has reviews saved like this....
I am looking to return the amount of reviews listed for a certain ID number. The table itself is called gg_reviews
I know this is real simple but for some reason its baffling me, can someone help?
Upvotes: 0
Views: 44
Reputation: 501
kk.. can't find there a way to see where you store the id.. but i would "suggest" the following:
SELECT ID, COUNT(ID) as views FROM gg_reviews GROUP BY ID
Upvotes: 0
Reputation: 29811
You don't say which ID you want to count reviews for, but provided that it's the page_id:
SELECT page_id, COUNT(*) as totalReviews
FROM gg_reviews
GROUP BY page_id
Upvotes: 0
Reputation: 247680
Unless I am missing something, you just need to COUNT()
and GROUP BY
. The GROUP BY
field should be the unique value for each page.
SELECT count(*) as TotalReview, ID -- change ID to the unique id for the page
FROM gg_reviews
GROUP BY ID -- change ID to the unique id for the page
Upvotes: 2