To resolve the issue with your SQL query (select * from test where name is null;), let’s analyze possible reasons it’s not working and their fixes:
Common Reasons & Solutions
The query syntax itself is correct, but it may not return results due to these issues:
1. No rows have name = NULL
If there are no records in the test table where the name column is explicitly NULL, the query will return an empty result.
How to verify:
Run this to check if any NULL values exist in the name column:
SELECT COUNT(*) FROM test WHERE name IS NULL;
If the result is 0, there are no NULLs in name.
2. The name column uses empty strings ('') instead of NULL
Many applications store blank values as empty strings (not NULL). If this is the case, your query won’t catch them.
Fix: Include empty strings in the condition:
SELECT * FROM test WHERE name IS NULL OR name = '';
3. Table/column name mismatch
- The table name might be misspelled (e.g.,
testsinstead oftest). - The column name might be case-sensitive (e.g.,
Nameinstead ofname—common in PostgreSQL with case-sensitive settings).
Fix: Double-check the table and column names. For case-sensitive columns, use quotes:
SELECT * FROM test WHERE "Name" IS NULL; -- if column name is case-sensitive
Final Check
If none of the above apply, ensure you’re connected to the correct database and schema where the test table exists.
Let me know if you need further help debugging!

作者声明:本文包含人工智能生成内容。