Can I remove Nulls in a column in a delete statement, that also uses IN?
Here is the following line, and all records with a STATUS (column name btw) in the string are being removed. Except the records with a NULL STATUS column.
DELETE FROM PRODUCTS
WHERE [STATUS] IN (NULL,'09','12','13','A1','C1','H1','J1','S1','T1');
No, you cannot include NULL in the IN clause. Think of the IN expanding to a series of ORs, so you’d have:
which will not give what you’re expecting. Instead, treat the NULL condition independent of the rest: