While getting a list of restaurant I want to join rating data in this list.
For example
Table1 – restaurant Columns: id, name, latitude, longitude
and
Table2 – ratings Columns: id, restaurant_id, rating (value options: 1, 2, 3, 4, 5)
Constructed this:
SELECT *, SUM(ratings.rating) AS total_rating_count
FROM restaurants
INNER JOIN ratings
ON ratings.restaurant_id = restaurants.id
This only returns me 1 restaurant. I also need the amount of ratings available per restaurant in able to calculate average rating.
Can use some direction on this.
EDIT: And while we are at it, I want to join another table with comments linked to restaurant. I should dive into this at the same time: What is the difference between Left, Right, Outer and Inner Joins?