IS NOT NULL condition is used in the WHERE clause to identify records that have a value for the specified condition.(records that are not null)
Syntax:
SELECT * FROM table_name WHERE column_name IS NOT 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 provided an email address:
SELECT id, email FROM employee WHERE email IS NOT NULL; id email -- ------- 101 bryan.walker@email.com 102 alex.carpenter@email.com 103 sam.white@egmail.com 104 john.barry@email.com 107 david.lee@email.com 109 tom.young@email.com