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 NULL as well as the PROPERTY_EXISTS predicate

To compare temporal values by instant or by representation, see Chronological comparison operators.

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:

Example graph of six unconnected Person nodes, each with name, age, and role properties, several also with an email property

To recreate the graph, run the following query in an empty Neo4j database:

CREATE (alice:Person {name:'Alice', age: 65, role: 'Project manager', email: '[email protected]'}),
       (cecil:Person {name: 'Cecil', age: 25, role: 'Software developer', email: '[email protected]'}),
       (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: '[email protected]'}),
       (eskil:Person {name: 'Eskil', age: 39, role: 'CEO', email: '[email protected]'})

Examples

Example 1. Comparison operators
Equality operator (=)
MATCH (n:Person)
WHERE n.role = 'Software developer'
RETURN n.name AS name, n.role AS role
Result
name role

"Cecil"

"Software developer"

"Cecilia"

"Software developer"

Rows: 2

Inequality operator (<>)
MATCH (n:Person)
WHERE n.role <> 'Software developer'
RETURN n.name AS name, n.role AS role
Result
name role

"Alice"

"Project manager"

"Charlie"

"Security engineer"

"Daniel"

"Director"

"Eskil"

"CEO"

Rows: 4

Less than operator (<)
MATCH (n:Person)
WHERE n.age < 39
RETURN n.name AS name, n.age AS age
Result
name age

"Cecil"

25

"Cecilia"

31

Rows: 2

Less than or equal operator (<=)
MATCH (n:Person)
WHERE n.age <= 39
RETURN n.name AS name, n.age AS age
Result
name age

"Cecil"

25

"Cecilia"

31

"Daniel"

39

"Eskil"

39

Rows: 4

Greater than operator (>)
MATCH (n:Person)
WHERE n.age > 39
RETURN n.name AS name, n.age AS age
Result
name age

"Alice"

65

"Charlie"

61

Rows: 2

Greater than or equal operator (>=)
MATCH (n:Person)
WHERE n.age >= 39
RETURN n.name AS name, n.age AS age
Result
name age

"Alice"

65

"Charlie"

61

"Daniel"

39

"Eskil"

39

Rows: 4

IS NULL operator
MATCH (n:Person)
WHERE n.email IS NULL
RETURN n.name AS name
Result
name

"Cecilia"

"Charlie"

Rows: 2

IS NOT NULL operator
MATCH (n:Person)
WHERE n.email IS NOT NULL
RETURN n.name AS name, n.email AS email
Result
name email

"Alice"

"[email protected]"

"Cecil"

"[email protected]"

"Daniel"

"[email protected]"

"Eskil"

"[email protected]"

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_EXISTS returns NULL (consistent with GQL semantics).

  • PROPERTY_EXISTS applies to node and relationship properties only. IS NOT NULL is 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:

Equivalent expressions
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.

Equivalent expressions
a < b = c <= d <> e;
a < b AND b = c AND c <= d AND d <> e

Syntax

Comparison operators

Syntax snippet extracted from the full Cypher grammar.
<comparison predicate> ::= <simple comparison predicand> [ <simple comparison predicate part 2> ...] 
<simple comparison predicate part 2> ::= <simple comp op> <advanced comparison predicand> 
<simple comparison predicand> ::= <advanced comparison predicand> [ <advanced comparison predicate part 2> ] 
<simple comp op> ::= "=" | <not equals operator> | <less than operator> | <greater than operator> | <less than or equals operator> | <greater than or equals operator> 
<advanced comparison predicand> ::= <arithmetic value expression> 
<advanced comparison predicate part 2> ::= <advanced comp op> <advanced comparison predicand> | <value type predicate part 2> | <null predicate part 2> | xref:expressions/predicates/string-operators.adoc[<normalized predicate part 2>] | <is labeled predicate part 2> 
<not equals operator> ::= "<>" 
<less than operator> ::= "<" 
<greater than operator> ::= ">" 
<less than or equals operator> ::= "<=" 
<greater than or equals operator> ::= ">=" 
<null predicate part 2> ::= "IS" [ "NOT" ] "NULL"
Railroad diagram of the snippet
Railroad diagram for 'expressions/comparison-operators'