Neo4j:如何使用DELETE子句返回UNION返回的结果?

时间:2016-10-13 04:07:04

标签: neo4j cypher

如何在下面的语句中执行DELETE子句?

MATCH (u:User {userId:'ce5e59de-af34-4dba-a134-8ff1de3696b6'})-[r:WRITE*..2]-(p) 
RETURN u,r,p 
UNION MATCH (u:User {userId:'ce5e59de-af34-4dba-a134-8ff1de3696b6'})-[r:COMMENT]-(p) 
RETURN u,r,p

1 个答案:

答案 0 :(得分:2)

您无法在已撰写的查询中添加DELETE,但您可以不同方式编写,以便独立删除每个步骤:

MATCH (u:User {userId:'ce5e59de-af34-4dba-a134-8ff1de3696b6'})
OPTIONAL MATCH (u)-[:WRITE*..2]-(p)
DETACH DELETE p
WITH DISTINCT u
OPTIONAL MATCH (u)-[:COMMENT]-(p)
DETACH DELETE u, p