使用 start with a= '起始ID' connect by prior a= b
a为子项,b为父项。
select F_CA_CODE,F_CA_PARENTCODE,LEVEL from RGT_UNIT start with F_CA_CODE = '0' connect by prior F_CA_CODE = F_CA_PARENTCODE
查询结果:
其中LEVEL为oracle内置函数
如果加入查询条件需要在start with前面加入:
select F_CA_CODE,F_CA_PARENTCODE,LEVEL from RGT_UNIT where LEVEL=3 start with F_CA_CODE = '0' connect by prior F_CA_CODE = F_CA_PARENTCODE
查询结果:
http://www.cnblogs.com/no27/p/4221650.html
===============================================
http://www.cnblogs.com/xfrog/archive/2010/10/10/1847462.html