参考地址:https://blog.csdn.net/qq_33656602/article/details/77750576
如果表中存在层次数据,则可以使用层次化查询子句查询出表中行记录之间的层次关系
基本语法:
[ START WITH CONDITION1 ]
CONNECT BY [ NOCYCLE ] CONDITION2
[ NOCYCLE ]
用法示例:
SELECT t.* FROM Score_Model t WHERE t.id = 552 OR t.pid = 552
SELECT t.* FROM Score_Model t START WITH t.id = 552 CONNECT BY PRIOR t.id = t.pid
SELECT t.* FROM Score_Model t START WITH t.id = 553 CONNECT BY t.id = PRIOR t.pid
SELECT t.* FROM Score_Model t START WITH t.id = 554 CONNECT BY t.id = PRIOR t.pid