Adas
Adas

Reputation: 309

How to provide multiple rating

I need to work in a rating system like this:

enter image description here

I created a table called review like this:

enter image description here

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.

enter image description here

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

Answers (1)

Philipp
Philipp

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

Related Questions