Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-19-2019 03:39 AM
How should I bound relationships in merge? For example, the following query works fine.
MERGE (dummy{name:'dummy'})-[r0:PARENT_OF]->(s0)
MERGE (dummy)-[:PARENT_OF]->(s0)-[:PARENT_OF]->(s1)
But it adds two relationships between dummy and s0.
When I add r0 to the second merge it gives me "Variable r0
already declared":
MERGE (dummy{name:'dummy'})-[r0:PARENT_OF]->(s0)
MERGE (dummy)-[r0:PARENT_OF]->(s0)-[:PARENT_OF]->(s1)
Also, the same error if I remove :PARENT_OF from it:
MERGE (dummy{name:'dummy'})-[r0:PARENT_OF]->(s0)
MERGE (dummy)-[r0]->(s0)-[:PARENT_OF]->(s1)
The nodes "dummy" and "s0" are bound correctly.
Solved! Go to Solution.
08-19-2019 05:21 AM
I think you want to create below pattern:
(dummy)-[:PARENT_OF]->(s0)-[:PARENT_OF]->(s1)
so for this simply , you can write below query
MERGE (dummy{name:'dummy'})-[r0:PARENT_OF]->(s0)
MERGE (s0)-[:PARENT_OF]->(s1)
you getting above errors because you using variables incorrectly .It will create ambiguity.
for avoiding that best practice is always use lable name with variable
08-19-2019 05:21 AM
I think you want to create below pattern:
(dummy)-[:PARENT_OF]->(s0)-[:PARENT_OF]->(s1)
so for this simply , you can write below query
MERGE (dummy{name:'dummy'})-[r0:PARENT_OF]->(s0)
MERGE (s0)-[:PARENT_OF]->(s1)
you getting above errors because you using variables incorrectly .It will create ambiguity.
for avoiding that best practice is always use lable name with variable
All the sessions of the conference are now available online