Composed queries
UNION, WHEN and NEXT enable the composition of multiple separate query branches within a single query.
UNION allows for combining the results of different queries.
WHEN enables conditional queries, where different query branches can be made to execute depending on a set of criteria.
Finally, NEXT allows for the linear composition of sequential queries, passing the return values from one query to the next.
As such, UNION, WHEN, and NEXT manage in different ways the execution flow and logic of queries and cannot be used in queries as regular clauses.
For more information, see:
-
Conditional queries (
WHEN) Cypher® 25 only Introduced in Neo4j 2025.06 -
Sequential queries (
NEXT) Cypher 25 only Introduced in Neo4j 2025.06