oracle樹形查詢

create table test
(ID NUMBER(18) not null,
name vaechar2(50),
parent_id NUMBER(18)
);

--查詢當前節點下的所有子節點
select * from test t start with t.id='當前節點ID' connect by prior t.id=t.parent_id;
--查詢當前節點的父節點或者父節點以上的節點
select * from test t start with t.id='當前節點ID' connect by t.id= prior t.parent_id;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章