oracle 递归查询父子关系记录

select lpad(' ',4*(level-1))||t.project_id project_id,t.parent_project_id
from PC_PROJECT_ASSOC t
start with project_id='xRFv29ZYbE'
connect by prior project_id = parent_project_id

 
strat with 指定层次开始的条件,即是说满足这个条件的行即可以做为层次树的最顶层
  
connect by prior指层之间的关联条件,即什么样的行是上层行的子行(自连接条件)

 
 

posted on 2011-08-23 21:40  kafony  阅读(651)  评论(0编辑  收藏  举报

导航