Reputation: 504
i want to create more replationships from one node in one query
MATCH (n:Type) WHERE n.user = "usr2"
MATCH (p:Test) WHERE p.name = "test1"
CREATE (n)-[:CONTAINS {amount:5}]->(p)
MATCH (p1:Test) WHERE p1.name = "test2"
CREATE (n)-[:CONTAINS {amount:-7}]->(p1)
but im getting invalid syntax.
is there any other way than this?
MATCH (n:Type) WHERE n.user = "usr2"
MATCH (p:Test) WHERE p.name = "test1"
CREATE (n)-[:CONTAINS {amount:5}]->(p);
MATCH (n:Type) WHERE n.user = "usr2"
MATCH (p:Test) WHERE p1.name = "test2"
CREATE (n)-[:CONTAINS {amount:-7}]->(p);
Because this doesnt seems to be very efficient for lot of records.
Upvotes: 1
Views: 142
Reputation: 41676
As the error message says, use WITH after create:
MATCH (n:Type) WHERE n.user = "usr2"
MATCH (p:Test) WHERE p.name = "test1"
CREATE (n)-[:CONTAINS {amount:5}]->(p)
WITH n
MATCH (p1:Test) WHERE p1.name = "test2"
CREATE (n)-[:CONTAINS {amount:-7}]->(p1)
:Type(user)
and :Test(name)
Upvotes: 2
Reputation: 11216
How about this? Matches up front and creates afterwards?
MATCH (n:Type) WHERE n.user = "usr2"
MATCH (p:Test) WHERE p.name = "test1"
MATCH (p1:Test) WHERE p1.name = "test2"
CREATE n-[:CONTAINS {amount:5}]->p
CREATE n-[:CONTAINS {amount:-7}]->p1
Upvotes: 2