select * from tname where age>15 start with parent_id is null connect by prior id=parent_id;

解决方案 »

  1.   

    please check sql reference about 'CONNECT BY ... START WITH'
    select * from
        (select * from tbl
         connect by id = prior parenet_id
          start with level = 0)
    where age>15; ***. columns like 'level', 'ancestor_id' are not needed in this case.
      

  2.   

    ancestor_id(爷爷id)和grade都是垃圾字段,删掉;
    然后建议不要使用00000这个ID,然后将所有根节点的parent_id都置为00000;