IS NULL condition is used in the WHERE clause to identify records that do not have a value.
Syntax:
SELECT * FROM table_name WHERE column_name IS NULL;
Consider an employee table as shown below:
id | first_name | last_name | department | salary | |
101 | bryan | walker | sales | 50,000 | bryan.walker@email.com |
102 | alex | carpenter | accounts | 55,000 | alex.carpenter@email.com |
103 | sam | white | sales | 60,000 | sam.white@egmail.com |
104 | john | barry | sales | 54,000 | john.barry@email.com |
105 | bill | wood | accounts | 65,000 | |
106 | robert | hopkins | support | 70,000 | |
107 | david | lee | support | 72,000 | david.lee@email.com |
108 | jack | sears | support | 65,000 | |
109 | tom | young | sales | 55,000 | tom.young@email.com |
Below is the SQL query to return employees that did not provide an email address:
SELECT * FROM employee WHERE email IS NULL; id first_name last_name department salary email --- --------- --------- ---------- ------ ------- 105 bill wood accounts 65000 106 robert hopkins support 70000 108 jack sears support 65000