Reputation: 743
There are two Nodes with label
{code: START}
{code: PLACED}
{code: DISPATCHED}
{code: DELIVERED}
{code: COMPLETED}
There exists a relationship between two nodes "HAS_STATUS". When the order proceeds I've made a relation of order with the respective status.
(start) (placed)
Status Status
\ /
\ /
Status----Order1------Status
(dispatched) | (delivered)
|
Status
(completed)
(start) (placed)
Status Status
\ /
\ /
Status----Order2------Status
(dispatched) (delivered)
I want to execute 2 queries:
For the first one it returns Order1 as expected:
Match (order:Order)-[:HAS_STATUS]-(status:Status) where status.code="COMPLETED" return order{.*}
For the second it returns Order1 and Order2 (It should return only Order2)
Match (order:Order)-[:HAS_STATUS]-(status:Status) where not status.code="COMPLETED" return order{.*}
Please help me on the second one. I hope my explaination made you clear about the scenario.
Thanks!
Upvotes: 0
Views: 269
Reputation: 6514
You could use the following two queries:
query:
Match (order:Order) WHERE (order)-[:HAS_STATUS]-(:Status{code:"COMPLETED"}) return order{.*}
query:
Match (order:Order) WHERE NOT (order)-[:HAS_STATUS]-(:Status{code:"COMPLETED"}) return order{.*}
Upvotes: 1