Testing for an Unknown Value
Another type of comparison tests for the absence or presence of a value. Use the IS NULL operator to test whether a value is unknown. To test for the presence of any value, use IS NOT NULL.
Testing for NULL
- Execute the following query to retrieve the names of employees who do not have phone extensions:
SELECT last_name, first_name, phone_ext FROM Employee=
WHERE phone_ext IS NULL
- The query should return rows for last names Sutherland, Glon, and Osborne.
- Now execute the statement using IS NOT NULL to retrieve the names of employees who do have phone extensions:
SELECT last_name, first_name, phone_ext FROM Employee
WHERE phone_ext IS NOT NULL
- There should be 39 rows in the result set.