其他分享
首页 > 其他分享> > 创建关系1

创建关系1

作者:互联网

create
(qiao:Person{name:"qiao"}),
(wang:Person{name:"wang"}),
(zhao:Person{name:"zhao"}),
(liang:Person{name:"liang"}),
(desk:Desk{num:123456}),
(qiao)-[:has_desk]->(desk),
(wang)-[:has_desk]->(desk),
(zhao)-[:has_desk]->(desk),
(zhao)-[:Friends{relation:"friend"}]->(qiao),
(zhao)-[:Friends{relation:"friend"}]->(liang)

1.共享信息

match(p1:Person)-[:has_desk]->(desk)<-[:has_desk]-(p2:Person)
where exists(desk.num)
with p1,p2
merge (p1)-[:Know{relation:"know"}]->(p2)

2.原有关系

match(p1:Person)-[r1:Friends{relation:"friend"}]->(p2:Person)
where exists(r1.relation)
with p1,p2
merge (p1)-[r2:Know{relation:"know"}]->(p2)

3.获取所需关系图

match  m=(p1:Person)-[:Know{relation:"know"}]->(p2:Person) return m

 

标签:关系,p2,p1,创建,Person,zhao,relation,desk
来源: https://www.cnblogs.com/hapyygril/p/10438979.html