When you are comparing a field to a null like field_name=NULL
you are comparing to a known data type from a field say varchar
to not only an unknown value but also an unknown data type as well, that is, for NULL
values. When comparison like field_name=NULL
again implies therefore a checking of data type for both and thus the two could not be compared even if the value of the field is actually NULL
thus it will always result to false
. However, using the IS NULL
you are only comparing for the value itself without the implied comparison for data type thus it could result either to false
or true
depending on the actual value of the field.
See reference here regarding the issue of NULL
in computer science and here in relation to the similarity to your question.
Now, for the IN clause (i.e. IN(NULL)
) I don't know what RDBMS you are using because when I tried it with MS SQL and MySQL it results to nothing.
See MS SQL example and MySQL example.