I want to do something like this:
SELECT
Users.id,
Countries.name
FROM
Users, Countries
WHERE
Users.country_id = Countries.id
The issue is that Users.country_id can sometimes be NULL, and if it is the entire row is not returned. I want it to return the row but with ‘null’ or ” in that column. I tried this:
SELECT
Users.id,
Countries.name
FROM
Users, Countries
WHERE
(Users.country_id = Countries.id OR Users.country_id IS NULL)
However that returns the row once for each *Countries.id* that exists. How do I work around this?
This is a good example of why the
ANSIjoin syntax (using theJOINkeyword) is preferred.