InterBase Quick Start: Part IV - Testing for an Unknown Value
Go Up to InterBase Quick Start: Part IV - Using the WHERE Clause
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
1.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, Glen, and Osborne.
2. 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.