How do you write a query to find rows with NULL values in a specific column?
Posted by BobHarris
Last Updated: July 24, 2024
To find rows with NULL values in a specific column in SQL, you can use the IS NULL condition in your SELECT statement. Here’s a general syntax for the query:
SELECT *
FROM table_name
WHERE column_name IS NULL;
Example
Suppose you have a table named employees and you want to find all rows where the department_id is NULL. The query would look like this:
SELECT *
FROM employees
WHERE department_id IS NULL;
This will return all rows from the employees table where the department_id column has a NULL value.
Related Content