Skip to content

Commit 73c86ba

Browse files
Top Level Braces docs
1 parent bbdd153 commit 73c86ba

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

modules/ROOT/pages/clauses/union.adoc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,42 @@ The combined result is returned, without duplicates.
124124
|Rows: 3
125125
|===
126126

127+
[[union-combining-distinct-and-all]]
128+
== Combining UNION DISTINCT and UNION ALL
129+
130+
It is not allowed to mix `UNION DISTINCT` and `UNION ALL` in the same chain of clauses.
131+
This can be solved by enclosing one or more `UNION` of the same type in curly braces
132+
allowing the enclosed query to be used as an argument to the outer `UNION`.
133+
134+
.Query
135+
[source, cypher]
136+
----
137+
{
138+
MATCH (n:Actor)
139+
RETURN n.name AS name
140+
UNION
141+
MATCH (n:Director)
142+
RETURN n.name AS name
143+
}
144+
UNION ALL
145+
MATCH (n:Movie)
146+
RETURN n.title AS name
147+
----
148+
149+
The combined result is returned.
150+
151+
.Result
152+
[role="queryresult",options="header,footer",cols="1*<m"]
153+
|===
154+
| name
155+
| "Johnny Depp"
156+
| "Sarah Jessica Parker"
157+
| "Ed Wood"
158+
| "Ed Wood"
159+
|Rows: 4
160+
|===
161+
162+
127163

128164
[[post-union-processing]]
129165
== Post-union processing

0 commit comments

Comments
 (0)