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递归查询记录,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。