0

I've used the following code to create relationship between two nodes:

MATCH (c1), (c2)
WHERE c1.name = "UK" AND c2.name = "London"
CREATE (c2)-[:IN]->(c1);

If I run it few times it will duplicate the relationship. I want to avoid possible duplication. What can I do?

Taja Jan
  • 942
  • 1
  • 1
  • 11

1 Answers1

0

To avoid duplication of relationship can use the MERGE clause instead CREATE:

MATCH (c1), (c2)
WHERE c1.name = "UK" AND c2.name = "London"
MERGE (c2)-[:IN]->(c1);
Taja Jan
  • 942
  • 1
  • 1
  • 11