3.sql中的向上遞歸和向下遞歸
阿新 • • 發佈:2017-09-19
ble 編碼 conn table where 包含 span 順序 ffffff start with bmbm(本級關聯條件)=‘610528000000‘(本級編碼)--包含本級
1.向下遞歸
select * from table_name where 條件 connect by prior bmbm(本級關聯條件)=sjbmbm(上級關聯條件) start with bmbm(本級關聯條件)=‘610000000000‘(本級編碼)--包含本級
select * from table_name where 條件 connect by prior bmbm(本級關聯條件)=sjbmbm(上級關聯條件) start with sjbmbm(本級關聯條件)=‘610000000000‘(本級編碼)--不包含本級
2.向上遞歸
select * from table_name where 條件 connect by prior sjbmbm(上級關聯條件)=bmbm(本級關聯條件)
select * from table_name where 條件 connect by prior sjbmbm(上級關聯條件)=bmbm(本級關聯條件) start with sjbmbm(本級關聯條件)=‘610528000000‘(本級編碼)--包含下級
註:向上遞歸和向下遞歸的區別在於中間關聯條件順序的不同,註意 start with 條件的意義也不同。
3.sql中的向上遞歸和向下遞歸