title: Access parent alias in subquery within a with clause using connect by in Oracle
body: <p>I'm trying to recursively get some data using connect by, which for each row I need to know if in a different tree contains a specific item.</p>
  
  <p>So I have this [stripped down] query:</p>
  
  <pre><code>select m.id, m.name,
     (select (
      with recursiveMetaClass as (
              select mb.name
              from meta mb
              start with mb.id = m.id
              connect by prior mb.metaclass = mb.id and mb.metaclass &lt;&gt; mb.id
      ) select name from recursiveMetaClass where name in ('config_group', 'config_item')
     ) from dual) as basetype
  from meta m
  inner join meta_rel mr on mr.rel2 = m.id
  start with m.name = 'store_sys'
  connect by prior m.id = mr.rel1
  order siblings by item_order;
  </code></pre>
  
  <p>This errors though with ORA-00904 "M"."ID": invalid identifier on m.id in start with in my nested query.  If I replace with query with:</p>
  
  <pre><code>select m.id, m.name,
     (select (
      with recursiveMetaClass as (
              select mb.name
              from meta mb
              start with mb.id = 1004
              connect by prior mb.metaclass = mb.id and mb.metaclass &lt;&gt; mb.id
      ) select name from recursiveMetaClass where name in ('config_group', 'config_item')
     ) from dual) as basetype
  from meta m
  inner join meta_rel mr on mr.rel2 = m.id
  start with m.name = 'store_sys'
  connect by prior m.id = mr.rel1
  order siblings by item_order;
  </code></pre>
  
  <p>It works (just gives wrong results).</p>
  
  <p>How can I either get m.id into that start with, or refactor this to work?  I also tried using some nested selects and doing a where on rownumber = 1 order by level desc, however I get the exact same error when trying to reference m.id.</p>
  
  <p>Thank you!</p>