ORACLE查詢樹型關系是怎樣的?
相關介紹:在oracle中start with connect by (prior) 用來對樹形結構的數據進行查詢。其中start with conditon 給出的是數據搜索范圍, connect by后面給出了遞歸查詢的條件,prior 關鍵字表示父數據,prior 條件表示子數據需要滿足父數據的什么條件。思路:列出所有子,然后判斷所列出的子下面再沒有子了select * from (select ID, parentid from tb start with id='B' connect by prior parentid = idunionselect ID, parentid from tb start with id='G' connect by prior parentid = id ) Awhere not exsits ( select 1 from tb b where A.id= B. parentid)你試試,我沒有環境。