How do I select rows where a column has no value in SQLite?
Quick answer
In SQLite, test a column for a missing value with IS NULL: SELECT id, notes FROM tasks WHERE notes IS NULL;. Do not use notes = NULL: an ordinary comparison with NULL evaluates to NULL, and a WHERE clause excludes rows when its expression is NULL. In the example below, only the row whose notes value is NULL is returned; ordinary text values are not.
The question, the details, the next step.
A practical checklist
Write the condition as
column_name IS NULLto select SQLNULLvalues.Use the actual table and column names in the query.
Do not use
column_name = NULLas a missing-value test.Check whether a blank-looking value is
NULLor an empty string before choosing a filter.Inspect values without a filter if you need to check what the column contains.
A few more useful answers
Does `IS NULL` also select an empty string?
No. An empty string is a stored text value, not SQL NULL. If you want both, test for column_name IS NULL OR column_name = ''.
Can I use `IS NULL` with a different column?
Yes. Replace the column name in WHERE with the column you want to check, for example WHERE completed_at IS NULL.
Does this guide establish the syntax for every SQL database?
No. The explanation and examples here describe SQLite. Check the documentation for your database engine before assuming its syntax or behavior is the same.
Sources
References used for this guide.
- [S1] SQLite SQL Language Expressions — NULL-aware operators sqlite.org · Checked
