oracle遞歸向上匯總 有沒有替代oracle中的startwith遞歸式查詢的方法?
有沒有替代oracle中的startwith遞歸式查詢的方法?相信你知道level在遞歸查詢中的意思,除了level之外,還有一個偽列:CONNECT_BY_ISLEAF。你可以在輸出的列中間加上CO
有沒有替代oracle中的startwith遞歸式查詢的方法?
相信你知道level在遞歸查詢中的意思,除了level之外,還有一個偽列:CONNECT_BY_ISLEAF。你可以在輸出的列中間加上CONNECT_BY_ISLEAF這個列,將會發(fā)現(xiàn)CONNECT_BY_ISLEAF為1的全是葉子節(jié)點,也就是你說的最底層。
ORACLE查詢樹型關系是怎樣的?
相關介紹:在oracle中start with connect by (prior) 用來對樹形結構的數(shù)據(jù)進行查詢。其中start with conditon 給出的是數(shù)據(jù)搜索范圍, connect by后面給出了遞歸查詢的條件,prior 關鍵字表示父數(shù)據(jù),prior 條件表示子數(shù)據(jù)需要滿足父數(shù)據(jù)的什么條件。思路:列出所有子,然后判斷所列出的子下面再沒有子了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)你試試,我沒有環(huán)境。