In the RETURN part of your query, you define which parts of the pattern you are
interested in. It can be nodes, relationships, or properties on these.
To return a node, list it in the RETURN statement.
Query.
MATCH (n { name: "B" })
RETURN n
The example will return the node.
To return a relationship, just include it in the RETURN list.
Query.
MATCH (n { name: "A" })-[r:KNOWS]->(c)
RETURN r
The relationship is returned by the example.
To return a property, use the dot separator, like this:
Query.
MATCH (n { name: "A" })
RETURN n.name
The value of the property name gets returned.
When you want to return all nodes, relationships and paths found in a query, you can use the * symbol.
Query.
MATCH p=(a { name: "A" })-[r]->(b)
RETURN *
This returns the two nodes, the relationship and the path used in the query.
Result
| b | a | r | p |
|---|---|---|---|
| 2 rows | |||
|
|
|
|
|
|
|
|
To introduce a placeholder that is made up of characters that are
outside of the english alphabet, you can use the ` to enclose the identifier, like this:
Query.
MATCH (`This isn't a common identifier`) WHERE `This isn't a common identifier`.name='A' RETURN `This isn't a common identifier`.happy
The node with name "A" is returned
If the name of the column should be different from the expression used, you can rename it by using AS <new name>.
Query.
MATCH (a { name: "A" })
RETURN a.age AS SomethingTotallyDifferent
Returns the age property of a node, but renames the column.
If a property might or might not be there, you can still select it as usual. It will be treated as NULL if it is missing
Query.
MATCH (n) RETURN n.age
This example returns the age when the node has that property, or null if the property is not there.
Any expression can be used as a return item — literals, predicates, properties, functions, and everything else.
Query.
MATCH (a { name: "A" })
RETURN a.age > 30, "I'm a literal",(a)-->()
Returns a predicate, a literal and function call with a pattern expression parameter.
Result
| a.age > 30 | "I'm a literal" | (a)-->() |
|---|---|---|
| 1 row | ||
|
|
|
Copyright © 2014 Neo Technology