So as far as I can tell, it is not possible to use where in a merge statement. Then how do I do multiple conditions?
What I want to achieve, but cannot work:
MERGE (n:Node)
WHERE n.key = "test1" OR n.key = "test2"
ON CREATE n.key = "test1"
return n
So how do I create an or condition on my merge statement? Or is there a better way to do it?
It does not look like MERGE supports the WHERE clause. However, you can specify ONE test value per property; for example:
MERGE (n:Node {key:'test1'})
RETURN n;
In your case, since you want to test for multiple values per property, there is no way to do that with MERGE
Also, if I understand what you are trying to do, it does not look like MERGE was the right thing to use anyway. I think the following Cypher code should give you the results that you are looking for:
MATCH (n:Node { key: "test1" })
RETURN n
UNION
OPTIONAL MATCH (n:Node { key: 'test2' })
SET n.key = 'test1'
RETURN 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