Skip to content
Advertisement

How can I get this query when a column is NULL?

I’m trying to execute this query to get a list of all users, groups and emails, but my problem is when the user is not related to any group, so the column radcheck.id_group is = NULL, but I still want to list it.

How can I write it correctly?

Advertisement

Answer

Use explicit, LEFT JOINs:

It is also often a good practice to use table aliases: they make the query easier to read and maintain (and also allow self-joining tables when needed…).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement