1
votes

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 ?

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. thanks!

thanks!

2

2 Answers

3
votes

try

start n1=node(1) , n2=node(2)  match n1-[r]->n2 return r
3
votes

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:

start n1 = node(1), n2 = node(2)
match n1-[r:knows]->n2
return r;