How to delete more than one relationship in neo4j using cypher?

Viewed 56

I want to remove more than one relationship but not all relationship for specific node,

I can delete single relationship or every relationship but not more than one specific relationship

match(n:Student{id:2),
(n)-[r1:STUDENT_CLASS]->(b:Class),
(n)-[r2:STUDENT_RANK]->(m:Rank)
delete r1,r2
return n.name

I connected Student node with 3 common nodes(School,Class,Rank) with different relationship. I want to delete 2 relationship(Class,Rank) for particular student in same query without affecting another node's(School) relationship with Student node.

1 Answers

Your query is logically correct but syntactically wrong:

match(n:Student{id:2), <--- missed a closing curly brace here
(n)-[r1:STUDENT_CLASS]->(b:Class),
(n)-[r2:STUDENT_RANK]->(m:Rank)
delete r1,r2
return n.name

Try this:

match(n:Student{id:2}),
(n)-[r1:STUDENT_CLASS]->(b:Class),
(n)-[r2:STUDENT_RANK]->(m:Rank)
delete r1,r2
return n.name
Related