 Rank: Administration Groups: Administration
Joined: 11/23/2008 Posts: 335 Points: 711 Location: Australia
|
If SELECT…NOT IN…(SELECT...) always filter all rows, it means that the IN list is null.
We need to ensure the list parameter or the second SELECT statement doesn’t include null value because null is not true - the WHERE clause only keeps true rows, so all rows are filtered. Please note that negating null results in null.
The key point is to eliminate the null value in the list by adding a condition test the value is not null in the WHERE clause of the sub query.
|