title: Hierarchical Queries in H2
body: <p>I have the following query, which works fine in <a href="https://www.oracle.com/uk/database/index.html" rel="nofollow">Oracle</a>:</p>
  
  <pre><code>SELECT ID
  FROM PEOPLE
    START WITH ID = &lt;person_id&gt; 
    CONNECT BY PRIOR PARENT_ID = ID;
  </code></pre>
  
  <p>This works on a self-referencing table, which contains people. It finds the ids of all ancestors of a person.</p>
  
  <p>The issue is that I need this query to also work in <a href="http://www.h2database.com/html/main.html" rel="nofollow">H2</a>, but <a href="https://groups.google.com/forum/#!topic/h2-database/GjfTo81L0bQ" rel="nofollow">H2 does not support <code>CONNECT BY PRIOR</code></a>. Therefore, <strong>how can I rewrite the above query so that it works with both Oracle and H2?</strong></p>