I have created some nodes and relationships within these. But while doing these something wrong happened. I want to delete all nodes having "SGS", except node with ID 2.
Following is script I ran to create node and relationships:
(Please also suggest how to EDIT this one, if possible)
I tried DELETE (along with match, where, IS NULL, etc) with some different trial and error methods but unable to achieve same. Please Help.
It looks like all your nodes have a name, except the node that you want deleted. So you can try
match n
WHERE NOT (HAS (n.name)) //find all nodes with no name property
with n
match n-[r]-() //find all nodes connected to that node
delete r,n //delete its relations and then the node itself
(note not tested)
Looks like in your create statement above, you've use (rkn) instead of (rk) and also probably (answ) instead of something else. So (rkn)-[:READ]->(bk1) will just create a node with no properties to represent rkn and a READ relation to OneNight@CallCenter. You just have to verify and fix those.
e.g. the relationships all refer to a node called (rkn) so I renamed the rk node in your create statement to rkn. Please also verify that every node you refer to in your relationships actually maps to a node in your create statement.
NOTE: HAS is no longer supported in Cypher, please use EXISTS instead!
This one worked for me
match (n) WHERE NOT (EXISTS (n.name)) DETACH DELETE n
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With