Use NULL within IN Clause won’t work
Sql query
Published in
1 min readOct 2, 2019
SELECT *
FROM tbl_name
WHERE id_field IN ('value1', 'value2', 'value3', NULL)
An in
statement will be parsed identically to field=value1 or field=value2 or field=value3
. Putting a null in there will boil down to field=null
which won't work.
I would do this for clairity
SELECT *
FROM tbl_name
WHERE (id_field IN ('value1', 'value2', 'value3') OR id_field IS NULL)