Database Reference
In-Depth Information
▼
Input
SELECT cust_id
FROM customers
WHERE cust_email IS NULL;
▼
Output
+---------+
| cust_id |
+---------+
| 10002 |
| 10005 |
+---------+
Caution
NULL
and Nonmatches You might expect that when you filter to select all rows that
do not have a particular value, rows with a
NULL
will be returned. But they will not.
Because of the special meaning of
unknown
, the database does not know whether they
match, and so they are not returned when filtering for matches or when filtering for non-
matches.
When filtering data, make sure to verify that the rows with a
NULL
in the filtered column
are really present in the returned data.
In this chapter, you learned how to filter returned data using the
SELECT
state-
ment's
WHERE
clause. You learned how to test for equality, nonequality, greater
than and less than, value ranges, and
NULL
values.