Mysql
 SQL >> Database >  >> RDS >> Mysql

Perché NOT IN non restituisce righe con NULL

Foo IN (A, B, C) equivale a Foo = A OR Foo = B OR Foo = C. Se la lista contiene NULL, Foo = NULL è UNKNOWN, trattato come falso nel filtro.

Quindi NOT IN con subquery che restituisce NULL può non restituire righe. Filtra i NULL o usa NOT EXISTS.