我正在尝试为列表中的所有ID创建朋友关系,但我收到错误:
y already declared (line 2, column 41 (offset: 64))
"Merge (y:User{id:"21",name:"b"})
Merge (y:User{id:"41",name:"d"})
Merge (y:User{id:"51",name:"e"}) "
^
Neo.ClientError.Statement.InvalidSyntax
我正在尝试创建一个具有id,name,year以及同时与现有节点关系的新用户。我该怎么做?还有其他任何方式吗?我非常感谢任何帮助。
MATCH (u:User {id:"2"})
Merge (y:User{id:"21",name:"b",year:"2010"})
Merge (y:User{id:"41",name:"d",year:"2011"})
Merge (y:User{id:"51",name:"e",,year:"2013"})
MERGE (u)-[:FRIEND]->(y)
答案 0 :(得分:3)
重复使用标识符y将无效。
尝试
MATCH (u:User {id:"2"})
unwind [{id:"21",name:"b",year:"2010"},
{id:"41",name:"d",year:"2011"},
{id:"51",name:"e",year:"2013"}] as user
merge (y:User {id: user.id, name: user.name,year:user.year})
MERGE (u)-[:FRIEND]->(y)