The syntax to check for nulls is:
WHERE WRT_Phone IS null;
Question
I am having an issue with filtering out phone numbers which have no value in them ie:
(___) ___ - ____
I tried this in my WHERE clause to get ALL the values that had a full phone number:
WHERE WRT_Phone <> null;
This allowed me to get all the phone numbers that had a full value in them. But, when I attempt
WHERE WRT_Phone = null;
Nothing gets populated in the resulting table. Are there any functions that I can use to turn the area code into a number or a function to check if phone number data type is null?
Also, I am using Access 2010 for executing the SQL statements.
Solution
The syntax to check for nulls is:
WHERE WRT_Phone IS null;
OTHER TIPS
To check for nulls you need to use IS NULL
:
WHERE WRT_Phone IS NULL
In fact, to check for not null, you should technically use IS NOT NULL
:
WHERE WRT_Phone IS NOT NULL
Something frankly odd (unique to Access?) is happening here because you should not be getting any results with WHERE WRT_Phone <> null
either.
Generally speaking, when NULL
is present on either side of a boolean operator or as part of an expression, the whole thing evaluates to NULL
(which is considered FALSE for the purposes of a WHERE clause):
WRT_Phone = NULL
expands to 'foobar' = NULL
which equals NULL -> no record returnedWRT_Phone <> NULL
expands to 'foobar' <> NULL
which equals NULL -> no record returnedWRT_Phone = NULL
expands to NULL = NULL
which equals NULL -> no record returnedWRT_Phone <> NULL
expands to NULL <> NULL
which equals NULL -> no record returned