IS NULL¶
Goal: Find missing values correctly. Understand why
field = NULLnever works.
NULL is "unknown"¶
In SQL, NULL means "we don't know" — not zero, not empty string, not false.
| Value | Meaning |
|---|---|
0 | The number zero |
'' | The empty string |
' ' | A space |
NULL | Unknown / missing |
These are all different.
Why = NULL doesn't work¶
Comparing anything to NULL with = or <> returns "unknown" — which WHERE treats as false.
The right way¶
Common patterns¶
Missing data¶
EMAIL IS NULL -- no email captured
PHONE IS NULL OR PHONE = '' -- no phone (NULL OR empty)
SURVEY_DATE IS NULL -- never surveyed
Find records that have data¶
Combine with other conditions¶
NULL vs empty string¶
These are not the same:
| Field value | IS NULL? | = ''? |
|---|---|---|
| (truly null) | ✅ | ❌ |
empty string '' | ❌ | ✅ |
(one space) | ❌ | ❌ |
If your data was imported from Excel or CSV, you might have a mix. Defensive query:
(TRIM is supported in most enterprise databases; in file gdb you can use Python Calculate Field to clean first.)
NULLs and arithmetic¶
Any arithmetic with NULL returns NULL:
To handle, use COALESCE (SQL Server, PostgreSQL):
In file geodatabases, this isn't always supported — calculate a clean field first.
NULLs with NOT¶
Excludes rows where STATE IS NULL — because STATE = 'GA' is unknown for nulls. To include them:
This is the "NULL trap" that bites everyone.
NULLs with IN¶
Same trap — excludes NULL states. Add OR STATE IS NULL if you need them.
NULLs in numeric fields¶
Excludes NULL POP rows (technically "unknown > 100000"). Usually that's fine. But for complement analysis, be explicit:
Quick checklist¶
When writing any query:
- Are there fields that might be NULL?
- Do I want NULLs included or excluded?
- If excluded, am I using
IS NOT NULL? - If included, do I have
OR field IS NULL?
Practice¶
Find the missing
Build queries that return:
- All schools that have no website.
- All cities with a population value (any number).
- All parcels not zoned residential, including those with no zoning info.
Answers: 1) WEBSITE IS NULL OR WEBSITE = '' 2) POP IS NOT NULL 3) (LANDUSE NOT LIKE 'Res%') OR LANDUSE IS NULL
→ Next: Numeric Filters.