Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete relation between two nodes?

Tags:

neo4j

cypher

I am unable to delete relation between two nodes. I am getting this result Returned 0 rows in 252 ms only. my query is:

MATCH (n: Company{ companyName : "Amagi Media Labs"})-[r: HAS_CUSTOMER]-(n: Company{ companyName : "IBN7"} ) delete r RETURN n,r;

How can I write this query.
Help is appreciated.

like image 230
Raghav Singh Avatar asked Aug 26 '26 19:08

Raghav Singh


1 Answers

You want to use different node identifiers for the two nodes you're matching, or it won't match either:

MATCH (n:Company {companyName:"Amagi Media Labs"})-[r:HAS_CUSTOMER]-(m:Company {companyName:"IBN7"})
DELETE r 
RETURN n,r;

Update: you can't return the relationship, so you'd only be able to RETURN n, m after the DELETE.

like image 76
Eve Freeman Avatar answered Aug 31 '26 03:08

Eve Freeman