I am trying to get all Nodes (node1) that have relationship (relationship of type R1) to node2 and not having (relationship of type R2). I tried to run this query :
MATCH node1 -[r1: R1]-> node2 WHERE node2.id = '1234' WITH node1,node2
OPTIONAL MATCH node1- [r2: R2]->node2 WHERE r2 is NULL
RETURN content
I am stil getting nodes that have r2 relationship in the resulte. what is wrong with my query?
I think what you want is MATCH
syntax in the WHERE
in a NOT
:
MATCH (node1)-[:R1]->(node2)
WHERE node2.id = '1234' AND NOT (node1)-[:R2]->(node2)
RETURN node1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.