I have this situation
CREATE (a:X { id: 1 })
CREATE (b:Y { id: 2 })
CREATE (c:Z { id: 3 })
CREATE (:Z { id: 4 })
CREATE (a)-[:HAS]->(d:W { id: 5 })<-[:HAS]-(b)
CREATE (c)-[:HAS]->(d)
And I want to run this query
MATCH (a:X { id: 1 })
MATCH (b:Y { id: 2 })
MATCH (c:Z { id: 4 }) // The one with no relationships yet
MERGE (a)-[:HAS]->(d:W)<-[:HAS]-(b), (d)<-[:HAS]-(c)
ON CREATE SET d.id = 6
The problem is that I'm not allowed to put more than one path in a single MERGE, how can I do this?
This is the result I want to achieve
Notice that I can't just do this
MATCH (a:X { id: 1 })
MATCH (b:Y { id: 2 })
MATCH (c:Z { id: 4 })
MERGE (a)-[:HAS]->(d:W)<-[:HAS]-(b) // This path already exists, but it uses the other `Z`
ON CREATE SET d.id = 6
MERGE (d)<-[:HAS]-(c) // Separate merge
Because the result would be


