Forum Moderators: open
If there are rows for that user in a user_ratings table, then select user in case his rating is 1. If there are no rows for that user, then select user without any exceptions.
Is it possible?
The following may work for you:
SELECT *
FROM users u LEFT OUTER JOIN user_ratings ur ON ur.user_id = u.id
WHERE ur.rating=1 OR ur.rating IS NULL
If a user can have multiple entries in the user_ratings table, then you'll need to use some more logic to filter out duplicates.