// 記錄
定義table tb_A sql
aid | pid | name |
|
|
|
select ... from tb_A -- 指定根節點 start with 條件一 -- 鏈接條件 connect by prior 條件二(前一條數據.字段一 = 目前數據.字段二) -- 結果集篩選 where 條件三
例: 查找PID = '1' 的全部子節點 spa
select × from tb_A start with pid = '1' connect by prior aid = pid;
例: 查找AID = '4' 的全部相關父節點 code
select * from tb_A start with aid = '4' connect by prior pid = aid;