I'm developing a rating system as part of a web application. I'm trying to run a query which returns the average for each entry in the data set. Below is the query I've started with:
SELECT hotel_id,
hotel_logo,
hotel_name,
hotel_website,
hotel_facebook,
hotel_rating,
hotel_verified,
hotel_location,
hotel_founded_in
FROM hotels
This works as expected and returns all the hotels & specified data fields.
To try and get the average of each set of reviews under a hotel I've used to following:
SELECT hotels.hotel_id,
AVG(review_total_rating),
hotel_logo,
hotel_name,
hotel_website,
hotel_facebook,
hotel_rating,
hotel_verified,
hotel_location,
hotel_founded_in
FROM hotels
INNER JOIN reviews
ON hotels.hotel_id = reviews.hotel_id
This query is returning the correct values but ONLY for a single row, I am also getting a MySQL warning saying there is no unique identifier.
How can I adjust the above query to bring back the specified data for every field in the table?
Any help appreciated.