NULL and NOT NULL
In SQL, NULL represents missing or unknown data.
It’s not the same as zero (0) or an empty string ('') — it simply means “no value.”
NULL Values
A column might contain NULL when information is missing — for example, if a client hasn’t provided an email yet.
Check for NULL with IS NULL
Use IS NULL or IS NOT NULL to check for missing values.
IS NULL returns TRUE when the value is NULL.
SELECT name FROM clients WHERE email IS NULL;
This query finds all clients who have provided an email address.
IS NOT NULL for Non-NULL Values
The IS NOT NULL operator returns TRUE if the value is not NULL.
SELECT name FROM clients WHERE email IS NOT NULL;
The example above shows how to find clients who have provided an email.
You cannot use = to compare with NULL. Use IS NULL or IS NOT NULL.
NOT NULL Constraint
The NOT NULL constraint prevents a column from having missing values.
For example, the query below creates a table with NOT NULL constraints on the id and name columns.
CREATE TABLE clients ( id INT NOT NULL, name TEXT NOT NULL, email TEXT, signup_date TEXT );
This ensures id and name are always provided.
Handling NULL properly ensures data integrity, accurate filtering and reporting, and fewer unexpected results in queries.
What does a NULL value represent in SQL?
A zero value
An empty string
Missing or unknown data
A duplicate entry
A formatting error
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help
Code Editor
Tables
Execution Result