Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-11-2022 05:46 PM
I have written below three queries and trying to understand difference between all 3 of them.
Query1:
MATCH (person)-[r]->(otherPerson)
Query2:
MATCH (person)-->(otherPerson)
Query3:
MATCH (person)--(otherPerson)
Please let me know if there is any difference between the three queries.
Solved! Go to Solution.
03-11-2022 08:19 PM
All three describe a direct relationship between a person node and an otherPerson node and the relationship type is not specified, i.e, a single relationship between the two nodes of any type.
The differences are:
Q1: specifies a direction and binds the relationship to a variable ‘r’, so that it can be referenced in your query. Variables are only needed if you need to reference the object.
Q2: specifies a directed relationship and does not bind the relationship to a variable. This is shorthand notation for (person)-->(otherPerson)
Q3: does not specify a direction, so relationships in either direction will match. This is shorthand for (person)--(otherPerson)
Hope this helps.
Sections 3-6 may help too.
03-11-2022 08:19 PM
All three describe a direct relationship between a person node and an otherPerson node and the relationship type is not specified, i.e, a single relationship between the two nodes of any type.
The differences are:
Q1: specifies a direction and binds the relationship to a variable ‘r’, so that it can be referenced in your query. Variables are only needed if you need to reference the object.
Q2: specifies a directed relationship and does not bind the relationship to a variable. This is shorthand notation for (person)-->(otherPerson)
Q3: does not specify a direction, so relationships in either direction will match. This is shorthand for (person)--(otherPerson)
Hope this helps.
Sections 3-6 may help too.
All the sessions of the conference are now available online