Oracle 查询树形所有节点名称

Oracle查询多级树形结点所有名称:

比如:上海下有浦东新区下有周浦,要查广东*广州*天河区 sql如下:

   select u.*
     from (select a.auto_id,
                  substr(SYS_CONNECT_BY_PATH(a.area_name, '*'), 2) area_name  //此处以*号分割名称
             from t_sys_area a
            where 1 = 1
            start with a.pid in (select pid
                                   from t_sys_area
                                  where 1 = 1
                                    and a.pid = '1')
       connect by prior a.auto_id = a.pid) u

Oracle 查询树形所有节点名称

相关推荐