I have a “ratings” table that contains (as a foreign key) identifier for what it is rated. Perhaps there are several ratings for a thing or not ratings for value.
I want to join the tables to see different ratings for all different identifiers, but now I have problems viewing things that don't have ratings. For instance:
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 a way to modify my selection request to also include identifiers that do not have ratings? I tried to change the statement to say where ratings.thingId = thing.id or thing.id > 0, but that doesn't seem to help.
Thank you and sorry if this is unclear.
source
share