您的位置:首页 > 博客中心 > 数据库 >

oracle递归查询记录

时间:2022-03-13 22:41

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

热门排行

今日推荐

热门手游