start with connect by prior 递归查询用法
select …,level from tablename start with 条件1 connect by 条件2 where 条件3
order by level desc ;
start with 子句:遍历起始条件,有个小技巧,如果要查父结点,这里可以用子结点的列,反之亦然。
connect by 子句:连接条件。关键词prior,prior跟父节点列parentid放在一起,就是往父结点方向遍历;prior跟子结点列subid放在一起,则往叶子结点方向遍历,
parentid、subid两列谁放在“=”前都无所谓,关键是prior跟谁在一起。
order by 子句:排序,不用多说。
参考资料https://www.cnblogs.com/benbenduo/p/4588612.html
We only live once, and time just goes by.

浙公网安备 33010602011771号