using the NOT IN operator on a column with null values

advertisements

I have a table employee which has a column company which has all null values

Now, I want to use a NOT IN operator for the company name as

select * from employee where employee.company NOT IN ('ABC', 'DEF')

Now technically this should not alter the result since the company column already had null values.

But adding the NOT IN gives 0 rows.

Is this due to the fact that employee.company column has NULL values?


Try this way:

select *
from employee E
where (E.company NOT IN ('ABC', 'DEF')
       or E.company is null)