1. 程式人生 > >oracle樹形結構全路徑查詢

oracle樹形結構全路徑查詢

and 語法 conn art join from 樹形 img ati


很實用的語法,父子節點通過id與patientId來關聯,知道子節點的id,想查出所有的父節點:

START WITH ...
CONNECT BY ...

SELECT T2.ORG_FULLNAME
  FROM SYS_ORG T
  LEFT JOIN SYS_ORG_MULTILANG T2
    ON T2.ORG_ID = T.ORG_ID
   AND T2.DICT_LANG_TYPE = en
 START WITH T.ORG_ID = 101230
CONNECT BY PRIOR T.ORG_PARENT_ID = T.ORG_ID

技術分享圖片

oracle樹形結構全路徑查詢