Comparison operators
Comparison operators are used to compare values. Cypher® contains the following comparison operators:
-
Equality:
= -
Inequality:
<> -
Less than:
< -
Greater than:
> -
Less than or equal to:
<= -
Greater than or equal to:
>= -
IS NULL -
IS NOT NULLas well as thePROPERTY_EXISTSpredicate
| For more information about how Cypher® orders and compares different value types, see Values and types → Equality, ordering, and comparison of value types |
Example graph
The following graph is used for the examples below:
To recreate the graph, run the following query in an empty Neo4j database:
CREATE (alice:Person {name:'Alice', age: 65, role: 'Project manager', email: 'alice@company.com'}),
(cecil:Person {name: 'Cecil', age: 25, role: 'Software developer', email: 'cecil@private.se'}),
(cecilia:Person {name: 'Cecilia', age: 31, role: 'Software developer'}),
(charlie:Person {name: 'Charlie', age: 61, role: 'Security engineer'}),
(daniel:Person {name: 'Daniel', age: 39, role: 'Director', email: 'daniel@company.com'}),
(eskil:Person {name: 'Eskil', age: 39, role: 'CEO', email: 'eskil@company.com'})
Examples
=)MATCH (n:Person)
WHERE n.role = 'Software developer'
RETURN n.name AS name, n.role AS role
| name | role |
|---|---|
|
|
|
|
Rows: 2 |
|
<>)MATCH (n:Person)
WHERE n.role <> 'Software developer'
RETURN n.name AS name, n.role AS role
| name | role |
|---|---|
|
|
|
|
|
|
|
|
Rows: 4 |
|
<)MATCH (n:Person)
WHERE n.age < 39
RETURN n.name AS name, n.age AS age
| name | age |
|---|---|
|
|
|
|
Rows: 2 |
|
<=)MATCH (n:Person)
WHERE n.age <= 39
RETURN n.name AS name, n.age AS age
| name | age |
|---|---|
|
|
|
|
|
|
|
|
Rows: 4 |
|
>)MATCH (n:Person)
WHERE n.age > 39
RETURN n.name AS name, n.age AS age
| name | age |
|---|---|
|
|
|
|
Rows: 2 |
|
>=)MATCH (n:Person)
WHERE n.age >= 39
RETURN n.name AS name, n.age AS age
| name | age |
|---|---|
|
|
|
|
|
|
|
|
Rows: 4 |
|
IS NULL operatorMATCH (n:Person)
WHERE n.email IS NULL
RETURN n.name AS name
| name |
|---|
|
|
Rows: 2 |
IS NOT NULL operatorMATCH (n:Person)
WHERE n.email IS NOT NULL
RETURN n.name AS name, n.email AS email
| name | |
|---|---|
|
|
|
|
|
|
|
|
Rows: 4 |
|
The IS NOT NULL predicate tests whether an expression evaluates to a non-NULL value.
For the GQL property existence predicate (GQL feature G115), see PROPERTY_EXISTS predicate.
PROPERTY_EXISTS predicate
The optional GQL feature G115 defines a PROPERTY_EXISTS(element, propertyName) predicate for testing whether a property exists on a node or relationship and is not NULL.
As of Neo4j 2026.03, Cypher® supports the GQL syntax:
MATCH (n:Person)
WHERE PROPERTY_EXISTS(n, email)
RETURN n.name AS name, n.email AS email
For node and relationship properties, this is equivalent to:
MATCH (n:Person)
WHERE n.email IS NOT NULL
RETURN n.name AS name, n.email AS email
Notes and differences:
-
The second argument must be a property name identifier (for example,
email). String literals and expressions are not allowed. -
If the element argument is
NULL,PROPERTY_EXISTSreturnsNULL(consistent with GQL semantics). -
PROPERTY_EXISTSapplies to node and relationship properties only.IS NOT NULLis more general and can be applied to any expression.
Chaining comparison operators
There is no limit on how many comparisons can be chained together.
If chaining two or more comparison operators, each comparison is effectively separated by an AND operator (though this AND is not required syntactically).
For example, if a, b, c, …, z are expressions and op1, op2, …, opN are comparison operators, then the following expressions are equivalent:
a op1 b op2 c ... y opN z;
a op1 b AND b op2 c AND ... y opN z
Note that a op1 b op2 c does not imply any kind of comparison between a and c.
For example, in x < y > z, x and z are not compared.
Chaining equality operators
Chains of = and <> are treated in a special way in Cypher®.
Specifically, 1=1=true is equivalent to 1=1 AND 1=true and not to (1=1)=true or 1=(1=true).
For example, the following expressions are equivalent.
a < b = c <= d <> e;
a < b AND b = c AND c <= d AND d <> e