SELECT id FROM customers WHERE type IS NOT Null;
Versus:
SELECT id FROM customers WHERE NOT type IS NULL;
The data th
IS NOT NULL
is a comparison operator, just like IS NULL
or =
, >
, <
, etc.
NOT
is a logical operator that acts on the rest of the condition. So you can say NOT type = 5
, NOT type IS NULL
, or even NOT type IS NOT NULL
.
My point here is to point out that they are two very different operators, even though the result is the same. Of course, in boolean logic, there is no difference between NOT (column IS NULL)
and column IS NOT NULL
, but it's wise to know the difference.
As for performance, IS NOT NULL
might save you a few cycles over NOT ... IS NULL
because you are using a single operator instead of two operators, but any reasonable optimizer will figure out they are the same thing before the query is run.