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