IS NOT NULL Operator - SQL
Overview
The IS NOT NULL Operator in SQL is used to filter the result set to include only the rows where the specified column does not contain a NULL value. It checks for the absence of NULL values in a column.
Syntax:
SELECT column
FROM table_name
WHERE column1 IS NOT NULL
column1 IS NOT NULL
checks if the value in column1
is not NULL.
Sample Data:
department_id | first_name |
---|---|
3 | Frank |
2 | Jane |
3 | Ashley |
NULL | Glenn |
2 | Kelly |
1 | Richard |
1 | George |
5 | Kyle |
2 | James |
1 | Gustavo |
Example
In this example, we are returning the department_id and the first_name column. We then use the IS NOT NULL operator to filter the results to only include rows where the department_id column is not null.
Example:
SELECT department_id, first_name
FROM company.employees
WHERE department_id IS NOT NULL