1. 程式人生 > >oracle 遞迴查詢整個路徑並行轉列組合成字串

oracle 遞迴查詢整個路徑並行轉列組合成字串

遞迴查詢路徑:

select * from t_db_organize connect by prior fartherid=id start with id='139312' order by id asc

這裡寫圖片描述

行轉列:

select replace(wm_concat(to_char(name)),',',' > ') name from(select * from t_db_organize connect by prior fartherid=id start with id='139312' order by id asc);

wm_concat:行轉列,預設逗號分隔,中文會亂碼,使用to_char可以避免

這裡寫圖片描述

參考地址:https://www.cnblogs.com/walk-the-Line/p/4882866.html