Oracle根據父類查出所有子類的函數--實現遞歸查詢(樹狀結構)

語法:

--向下遞歸遍歷
select * from tablename start with cond1
connect by cond2
where cond3;

select *        
from Table        
start with id = 1    //以哪個ID爲開始,即跟節點ID
connect by prior id = parent_id     //鏈接通過前一個ID和現在的父ID相等,定義子節點和父節點的關係
order by id ;    //排個序

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章