I recently realized that we need to use a special syntax
IS NULL to compare a literal to NULL.
= NULL not work here?
Take a look at PSOUG's notes on NULL. As Fabricio Araujo hinted, NULL is not really a value like the number 4 or string 'bacon strips'. In fact, NULL is untyped in the SQL language, which is why you cannot validly use it in an equality comparison. You need the special
In SQL Server, we have an connection setting to get
The recommended is the SQL Standard way - the
(And I will not start an war whether 'NULL is a value or a status' here)... hehehe
Rather than justify the
Here is an excellent essay on the subject from a postgres perspective. Briefly summed up by saying nulls are treated differently depending on the context and don't make the mistake of making any assumptions about them.
Oracle treats NULL as an unknown value. Ask yourself if this equality works.
or otherwise stated
The answer is clearly maybe, which is neither true nor false.
EDIT: In response to the comments I will add a little clarification to NULL as I have seen it used.
While NULL really means "not set", in the context of this question I believe the above statement is correct.
There are a number of reasons for a column to have a NULL value:
In some contexts, NULL may be handled in ways that might be considered incorrect, including: