My question:
I am new to Neo4j and trying to create a query listing nodes and relationships into a graph with keyword as "id=0001" as below:
(a) - [id:'0001', ref_id:null] -> (b) - [id:'0002', ref_id:'0001'] -> (c) - [id:'0003', ref_id:'0002'] -> (d)
Start Node will be (a) since it has relationship with id=0001
But the database also exists relationships which I don't want:
(a) - [id:'2001', ref_id:null] -> (b) - [id:'2002', ref_id:'2001'] -> (c)
(a) - [id:'3001', ref_id:null] -> (b) - [id:'3002', ref_id:'3001'] -> (c)
The result should only includes:
(a)-[0001]-(b)-[0002, 0001]-(c)-[0003,0002]-(d)
Below are what I was thinking before write question:
I know how to create this query in SQL database like Oracle and MySQL, I can use query with "where" condition. For example:
Select *
from table_a parent, (select * from table_a) child
where child.ref_id = parent.id
Then I can loop the result set in Java to find all relationships. But this is stupid.
I think the query should looks like:
Match (n)-[r:RELTYPE]->(m) WHERE {some conditions at here} RETURN n,r,m
Please help me, thank you!
Yufan