I have a “ratings” table, that contains (as a foreign key) the ID for the thing that it is rating. There are possibly multiple ratings for a thing, or no ratings for a value.
I want to join tables to see the different ratings for all the different IDs, but right now I’m having trouble viewing things that have no ratings. For example:
mysql> select avg(ratings.rating), thing.id from ratings, things where ratings.thingId = thing.id group by thing.id;
+----------------------+----+
| avg(ratings.rating) | id |
+----------------------+----+
| 6.3333 | 1 |
| 6.0000 | 2 |
+----------------------+----+
Is there any way to modify my select query to also include IDs that have no ratings? I tried modifying the statement to say where ratings.thingId = thing.id or thing.id > 0 but that doesn’t seem to help.
Thanks and sorry if it’s unclear.
1 Answer