10.8. Working with NULL
Introduction to NULL in Cypher
NULL is used to represent missing or undefined values.
NULL means “a missing unknown value” and it is treated somewhat differently from other values.
For example getting a property from a node that does not have said property produces
Most expressions that take
NULL as input will produce
This includes boolean expressions that are used as predicates in the
In this case, anything that is not
TRUE is interpreted as being false.
NULL is not equal to
Not knowing two values does not imply that they are the same value.
So the expression
NULL and not
Logical operations with NULL
The logical operators (
NULL as the “unknown” value of three-valued logic.
Here is the truth table for
|a||b|| a || a || a |
The IN operator and NULL
IN operator follows similar logic.
If Cypher knows that something exists in a collection, the result will be
Any collection that contains a
NULL and doesn’t have a matching element will return
Otherwise, the result will be false.
Here is a table with examples:
2 IN [1, 2, 3]
2 IN [1,
2 IN [1, 2,
2 IN 
2 IN 
SINGLE follows a similar rule.
If the result can be calculated definitely,
FALSE is returned.
NULL is produced.
Expressions that return NULL
Getting a missing element from a collection:
Trying to access a property that does not exist on a node or relationship:
Comparisons when either side is
1 < NULL
Arithmetic expressions containing
1 + NULL
Function calls where any arguments are