用法:
select ...
from tablename
start with 条件1
connect by 条件2where 条件3;
select * from table
start with org_id = 'HBHqfWGWPy'
connect by prior org_id = parent_id;
条件1 是根结点的限定语句,当然可以放宽限定条件,以取得多个根结点,实际就是多棵树。
条件2 是连接条件,其中用PRIOR表示上一条记录,比如 CONNECT BY PRIOR org_id = parent_id就是说上一条记录的org_id 是本条记录的parent_id,即本记录的父亲是上一条记录。
条件3 是过滤条件,用于对返回的所有记录进行过滤。
详细原文地址:http://hi.baidu.com/a889275/item/1ebf2780b48e72e3e596e048