Reputation: 309
I need to work in a rating system like this:
I created a table called review like this:
I have tried this query.
SELECT AVG(`food`) as foodavg FROM review where `restaurant_id` = '10'
But it gives average of only food. and i need to show the result for every restaurant like this.
Please tell me whether this structure is correct. I couldn't figure out a query to show average rating of single restaurant. Will it be using some join, or nested select query?
Please provide any solution to it. Thank you.
Upvotes: 2
Views: 755
Reputation: 83
I don't have too much expierience with SQL, but i think what you are looking for is:
SELECT (AVG(`food`)+AVG(`staff`)+AVG(`value`)+AVG(`atmosphere`))/4 FROM review
where `restaurant_id` = '10'
Upvotes: 3