如何在Neo4j中使用cypher在两个节点之间创建属性

时间:2022-08-09 18:02:21

I would like to do something like this

我想做这样的事情

START n=node(*), m=node(*)  where has(n.userid) and has(m.userid) and n.userid='0' and m.userid='3'  create (n)-[FRIENDSHIP {status:2}]->(m) ;

However, Neo4j doesn't like the where clause. What is the best way to do this?

但是,Neo4j不喜欢where子句。做这个的最好方式是什么?

Thanks a lot!

非常感谢!

1 个解决方案

#1


8  

What error did you get indicating that Neo4j didn't like the where clause?

你得到的错误表明Neo4j不喜欢where子句?

I ran

START n=node(*), m=node(*)  
where has(n.name) and has(m.name) and n.name='Neo'
create (n)-[:FRIENDSHIP {status:2}]->(m)

on console.neo4j.org and it ran fine. Note that you missed the : preceding the relation name. Was that the error it complained about?

在console.neo4j.org上它运行正常。请注意,您错过了关系名称前面的:这是它抱怨的错误吗?

What version are you using in case this still does not work?

如果这仍然不起作用,您使用的是什么版本?

#1


8  

What error did you get indicating that Neo4j didn't like the where clause?

你得到的错误表明Neo4j不喜欢where子句?

I ran

START n=node(*), m=node(*)  
where has(n.name) and has(m.name) and n.name='Neo'
create (n)-[:FRIENDSHIP {status:2}]->(m)

on console.neo4j.org and it ran fine. Note that you missed the : preceding the relation name. Was that the error it complained about?

在console.neo4j.org上它运行正常。请注意,您错过了关系名称前面的:这是它抱怨的错误吗?

What version are you using in case this still does not work?

如果这仍然不起作用,您使用的是什么版本?