PostgreSQL – IS NULL operator
The PostgreSQL IS NULL operator is used to check if a value is NULL or not. In the world of database Null either means data is missing or not applicable. Hence, it cannot be compared with any integer or string as this kind of comparison always leads to a Null meaning an unknown result.
Syntax: Value IS NULL;
For the sake of this article we will be using the sample DVD rental database, which is explained here and can be downloaded by clicking on this link in our examples.
Now, let’s look into a few examples.
Example 1:
Here we will make a query to find all the “first_name” and “last_name” of customers that don’t have an “email” in the “customer” table of our sample database.
SELECT first_name, last_name FROM customer WHERE email IS NULL;
Output:
Example 2:
Here we will make a query to find all the “title” of the films that don’t have a “release_year” in the “film” table of our sample database.
SELECT title FROM film WHERE release_year IS NULL;
Output:
Contact Us