connect by prior 是结构化查询中用到的,其基本语法是:
select ... from tablename start with 条件1
connect by prior 条件2
where 条件3;
★从Root往树末梢递归:
Sql代码
select * from tablename
start with id=1
connect by prior id = pid
★从末梢往树ROOT递归:
Sql代码
select * from TBL_TEST
start with id=10
connect by prior pid = id
select ... from tablename start with 条件1
connect by prior 条件2
where 条件3;
★从Root往树末梢递归:
Sql代码
select * from tablename
start with id=1
connect by prior id = pid
★从末梢往树ROOT递归:
Sql代码
select * from TBL_TEST
start with id=10
connect by prior pid = id