EdWood
EdWood

Reputation: 907

Create unique node with many relationships in one cypher query

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.

Upvotes: 1

Views: 922

Answers (1)

EdWood
EdWood

Reputation: 907

Solved

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

Upvotes: 2

Related Questions