Checking for NULLS
Before we learn to handle NULL
values, let's define a NULL
value. NULL
equals nothing in SQL, so a field that has no value is considered NULL
. Usually, NULL
fields are the result of having optional fields in your tables.
Checking NULL
values can be done using the following two special keywords, as it cannot be done using the logical operators:
IS NULL
IS NOT NULL
Note
An important point to highlight is the fact that fields with a value of
0
, or invisible characters such as spaces, are not consideredNULL
.NULL
fields are fields that are left blank.
Exercise 5.06: Searching for NULL Values
Ideally, we want all customers' first names to be in our system. For any customer whose first name is missing from our data, we want to contact the customer and ask them about the missing information. To do this, we require a report of all the customers with missing first names:
- Retrieve the middle name, last name, and phone number columns...