Variables

This page provides an overview of variables in Cypher®.

When you reference parts of a pattern or a query, you do so by naming them. The names you give the different parts are called variables.

In this example:

MATCH (n)-->(b)
RETURN b

The variables are n and b.

Information regarding the naming of variables may be found here.

Variables are only visible in the same query part

Variables are not carried over to subsequent queries. If multiple query parts are chained together using WITH, variables defined in one part have to be listed in the WITH clause to be carried over to the next part. For more information see WITH.

Variables imported into a CALL subquery are visible in the whole subquery

Even if the subquery consists of multiple query parts chained together using WITH, variables imported from the outer query do not have to be listed in a WITH clause to be visible in subsequent parts of the subquery. For more information see The variable scope clause.