oracle递归查询记录

1. start with  开始的id  connect by prior 开始的id=父id

2. level 级别

3.实例

select * from (

select a.*,level tt from biz_district a start with district_id=8 connect by prior district_id=parent_id

) where tt=3


select a.district_id,

       a.district_name,

       b.district_id   as district_id_1,

       b.district_name as distract_name_1

  from (select * from biz_district where parent_id = 8) a

  left join (select *

               from (select a.*, level tt

                       from biz_district a

                      start with district_id = 8

                     connect by prior district_id = parent_id)

              where tt = 3) b

    on a.district_id = b.parent_id


oracle递归查询记录,布布扣,bubuko.com

oracle递归查询记录

上一篇:SQL之用户自定义函数


下一篇:SQL collate