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

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:

predicate operators

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

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"

"alice@company.com"

"Cecil"

"cecil@private.se"

"Daniel"

"daniel@company.com"

"Eskil"

"eskil@company.com"

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