Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ The only way to guarantee row order in Neo4j is to use xref:clauses/order-by.ado
| 14.11
| <return statement>
| xref:clauses/return.adoc[`RETURN`]
| GQL defines the option to specify `RETURN ALL` (functionally equivalent to using `RETURN` on its own).
This is currently not available in Cypher.
|

| 15.4
| <conditional statement>
Expand Down
23 changes: 23 additions & 0 deletions modules/ROOT/pages/clauses/return.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,26 @@ The `Movie` node `'Man of Tai Chi'` is returned by the query, but only once (wit
d|Rows: 1
|===

[[return-all-results]]
== RETURN ALL

Returning all results can also be accomplished by explicitly including `ALL` in the `RETURN`.
The `RETURN ALL` keyword was introduced as part of Cypher's xref:appendix/gql-conformance/index.adoc[], and using it is functionally the same as using simple `RETURN`.

.Query
[source, cypher]
----
MATCH (p:Person {name: 'Keanu Reeves'})-->(m)
RETURN ALL m
----

The same node is returned twice, as there are two relationships connecting to it from `'Keanu Reeves'`.

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| m
| {"title":"Man of Tai Chi","released":2013}+
| {"title":"Man of Tai Chi","released":2013}+
d|Rows: 1
|===
53 changes: 53 additions & 0 deletions modules/ROOT/pages/clauses/with.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,56 @@ As the limit is larger than the total number of remaining rows, all rows are ret
| 6
|Rows: 4
|===

[[with-unique-results]]
== Unique results

`DISTINCT` retrieves only unique rows for the columns that have been selected for projection.

.Query
[source, cypher]
----
MATCH (n)-[:KNOWS]->(p)
WITH DISTINCT p.name AS name
RETURN name
----

`'George'` is returned by the query, but only once (without the `DISTINCT` operator it would have been returned twice because there are two `KNOWS` relationships going to it):

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| name
| "Bossman"
| "George"
| "Anders"
d|Rows: 3
|===


[[with-all-results]]
== WITH ALL

Projecting all results can also be accomplished by explicitly including `ALL` in the `WITH`.

Comment on lines +264 to +268
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't introduced for GQL compliance, WITH doesn't exist in GQL, it was introduced for consistency

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, sorry!

.Query
[source, cypher]
----
MATCH (n)-[:KNOWS]->(p)
WITH ALL p.name AS name
RETURN name
----

The same name is returned twice, as there are two `KNOWS` relationships connecting to it.

.Result
[role="queryresult",options="header,footer",cols="1*<m"]
|===
| name
| "Bossman"
| "George"
| "George"
| "Anders"
d|Rows: 4
|===

Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,29 @@ RETURN cosh(0.5), coth(0.5), sinh(0.5), tanh(0.5)
----
| Introduction of four new hyperbolic trigonometric Cypher functions.
For more information, see xref:functions/mathematical-trigonometric.adoc[Mathematical functions - trigonometric].

a|
label:functionality[]
label:new[]
[source, cypher, role=noheader]
----
MATCH (n)
RETURN ALL n.prop AS prop
----
| The keyword `ALL` can now be added after a xref:clauses/return.adoc#return-all-results[RETURN] as the explicit form of a `RETURN` without duplicate removal.

a|
label:functionality[]
label:new[]
[source, cypher, role=noheader]
----
MATCH (n)
WITH ALL n.prop AS prop
RETURN prop
----
| The keyword `ALL` can now be added after a xref:clauses/with.adoc#with-all-results[WITH] as the explicit form of a `WITH` without duplicate removal.


|===

[[cypher-deprecations-additions-removals-2025.03]]
Expand Down