Null
is a special value that represents an unknown value. Any arithmatic operation (+,-,*, /
) that has at least one Null
operand results in Null
. The same thing applies with comparisons: All comparisons with Null
would result in Null
. Even Null = Null
returns Null
. Therefore,
and
operator:true and Null
results inNull
false and Null
results infalse
Null and Null
results inNull
or
operator:true or Null
results intrue
false or Null
results inNull
Null or Null
results inNull
not
operator:not Null
results inNull
- To test if a value is
Null
, useIS NULL
orIS NOT NULL
- In
where
clause, recods that evaluates to eitherfalse
orNull
are excluded - Aggregation functions such as
sum
andaverage
discardNull
records count(*)
returns the number of records in a table. Butcount(field)
returns the number of notNull
records in the table. This means if the field is empty (Null
values only),count(field)
will return zero.