86
86
In the following example, `NEXT` passes the variable `customer` to the second query:
87
87
88
88
.Passing a variable to another query via `NEXT`
89
+ tag::sequential_queries_basic_example[]
89
90
[source,cypher]
90
91
----
91
92
MATCH (c:Customer)
96
97
MATCH (customer)-[:BUYS]->(:Product {name: 'Chocolate'})
97
98
RETURN customer.firstName AS chocolateCustomer
98
99
----
100
+ end::sequential_queries_basic_example[]
99
101
100
102
.Result
101
103
[role="queryresult",options="header,footer",cols="1*<m"]
@@ -152,6 +154,7 @@ This particularly useful when aggregating values.
152
154
In the following example, `NEXT` passes the variable `customer` to the second query:
153
155
154
156
.Aggregation after `NEXT`
157
+ tag::sequential_queries_aggregation_example[]
155
158
[source,cypher]
156
159
----
157
160
MATCH (c:Customer)-[:BUYS]->(p:Product)
162
165
RETURN product.name AS product,
163
166
COUNT(customer) AS numberOfCustomers
164
167
----
168
+ end::sequential_queries_aggregation_example[]
165
169
166
170
.Result
167
171
[role="queryresult",options="header,footer",cols="2*<m"]
@@ -186,6 +190,7 @@ RETURN product.name AS product,
186
190
When a `UNION` query follows a `NEXT` the full table of intermediate results are passed into all arms of the `UNION` query.
187
191
188
192
.`UNION` after `NEXT`
193
+ tag::sequential_queries_union_example[]
189
194
[source,cypher]
190
195
----
191
196
MATCH (c:Customer)-[:BUYS]->(p:Product)
201
206
202
207
RETURN * ORDER BY name, type
203
208
----
209
+ end::sequential_queries_union_example[]
204
210
205
211
.Result
206
212
[role="queryresult",options="header,footer",cols="3*<m"]
0 commit comments