简体   繁体   中英

how to match 2 nodes by relationship in Neo4j?

Given a list of (let say 4) MicroRNA and a list of relationships (pictar, rna22,…), returns the list of target TargetGenes common to all MicroRNA in all relationships.

I am trying to do by this way but it does not work...

MATCH (n:microRNA)-[r]->(n:Target) 
WHERE r.name='RNA22v2' 
OR r.name='PicTar' 
RETURN n 

But it does not give me any results.

This may or may not be the actual problem, but instead of

MATCH (n:microRNA)-[r]->(n:Target) 
WHERE r.name='RNA22v2' 
OR r.name='PicTar' 
RETURN n 

shouldn't you have

MATCH (m:microRNA)-[r]->(t:Target) 
WHERE r.name='RNA22v2' 
OR r.name='PicTar' 
RETURN m,t

Using the same variable n for two different nodes may confuse things.

Hope this helps, Tom

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM