Comparing Nullable values in PostgreSQL
PostgreSQL treats NULL
values a bit different than most of the languages we work with. Said that, if you try this:
SELECT * FROM users WHERE has_confirmed_email <> TRUE
This would return users with has_confirmed_email = FALSE
only, so NULL
values that you have on your DB would be ignored. In this case if you want to get users with has_confirmed_email
as FALSE
or NULL
then you can use IS DISTINCT FROM:
SELECT * FROM users WHERE has_confirmed_email IS DISTINCT FROM TRUE
Tweet