就不转载原文了,来个更加简单易懂的说法.
有数据表 a:
no upno
010102 0101
010101 0101
0101 01
01
select * from a start with no='010101' connect by no=prior upno;
查询结果为:
010101
0101
01
将upno和no换个位置:
select * from a start with no='0101' connect by upno=prior no;
查询结果为:
0101
010101
010102
注:
select * from emp connect by upno=prior no start with no='0101';
//与select * from a start with no='0101' connect by upno=prior no;效果一致
与select * from emp connect by prior upno=no start with no='0101';效果相反
重点在于prior的位置
原文:http://www.cnblogs.com/linjiqin/p/3152690.html:
select * from a start with no='010101' connect by no=prior upno;