[英]how to get a relationship between two nodes in graph-database using cypher query?
I want to get a relationship between two nodes ? 我想获得两个节点之间的关系吗?
if there is a relation node(1) [:knows] node(2)
how do i get the relationship by using cypher query ? 如果有关系
node(1) [:knows] node(2)
如何使用密码查询获得关系?
START r=node(196), s=node(198) MATCH r-[rel:knows]->s RETURN TYPE(rel)
this gives what I want. 这给出了我想要的。
But since there could be different relationships between two node for example 但是由于例如两个节点之间可能存在不同的关系
node1 -[:knows]->node2
node1 -[:friendrequest]->node 12
basically, i want to send nodes to the query and return whether relation is knows or friendrequest. 基本上,我想将节点发送到查询,并返回关系是否已知或friendrequest。 thanks!
谢谢!
thanks! 谢谢!
尝试
start n1=node(1) , n2=node(2) match n1-[r]->n2 return r
Aside from @Joerg's answer, consider that you only want the knows relationship, so you'd do something like this, otherwise you'd end up potentially returning multiple relationship nodes between n1
and n2
: 除了@Joerg的答案之外,请考虑您只希望知道关系,因此您将执行以下操作,否则最终可能返回
n1
和n2
之间的多个关系节点:
start n1 = node(1), n2 = node(2)
match n1-[r:knows]->n2
return r;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.