1
votes

I have set of nodes with property "x". I want to create node with property "y" and make relationships to "x" nodes in one query. I made this query:

MATCH (x) WHERE has(x.x) CREATE (y{y:"y"}), (y)-[:REL]->(x); 

This makes two nodes "y" and each of them have one relationship to "x", but I want one node "y" and from this node two relationships to every "x" node.

1
Have you tried using MERGE for your y node, something like MERGE (y{y:"y"}) CREATE y-[:REL]->x?jjaderberg

1 Answers

2
votes

Solved

MATCH (x) WHERE HAS (x.x) MERGE (y { y:"y" }) CREATE (y)-[:REL]->(x);