When using a NOT IN filter, rows where the column value is NULL are excluded from the results, even though NULL is not in the list of values. This is because SQL treats comparisons with NULL as UNKNOWN, which prevents those rows from being returned.
How to include NULL in NOT IN results:
To include rows with NULL values, add an explicit condition checking for NULL using OR column IS NULL.
Example:
SELECT *
FROM players
WHERE playerid NOT IN (1, 2, 3) OR playerid IS NULL;
This query will include rows where playerid is either NOT IN the list or is NULL, ensuring that NULL values are part of the result set.