我想在一个查询中从一个节点创建更多重播
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)
但我的语法无效。
还有其他方法吗?
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);
因为这对许多记录来说似乎不是很有效。
答案 0 :(得分:2)
这个怎么样?事先匹配并在之后创建?
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
答案 1 :(得分:2)
如错误消息所示,请在创建后使用WITH:
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)
和:Test(name)