
求助:圖片中左側為一張表中的資料,想要得到右側的結果,SQL怎么實作?
uj5u.com熱心網友回復:
邏輯關系沒看懂
uj5u.com熱心網友回復:
with tab1 as (
select table_id1, table_id2
from table_a
start with table_id1 = 'TABLE_A'
connect by prior table_id2 = table_id1
)
select table_id1 from tab1
union
select table_id2 from tab1
order by table_id1
;
uj5u.com熱心網友回復:
select COLUMN1
from test_insert3
start with COLUMN1 = 'T_A'
connect by prior COLUMN2 = COLUMN1
UNION
select COLUMN2
from test_insert3
start with COLUMN1 = 'T_A'
connect by prior COLUMN2 = COLUMN1
uj5u.com熱心網友回復:
select dept_name from (select t.dept_id, t.dept_name, t.dept_code, t.par_dept_id, level
from SYS_DEPT t
start with t.dept_id = '40288ac45a3c1e8b015a3c28b4ae01d6'
connect by prior t.dept_id = t.par_dept_id
order by level, t.dept_code) order by level
uj5u.com熱心網友回復:
我也沒看到這個結果是怎么回事?沒看出樹狀結構來uj5u.com熱心網友回復:
select DISTINCT TABLE_ID1 FROM TABLE_AUNION
select DISTINCT TABLE_ID2 FROM TABLE_A
uj5u.com熱心網友回復:
這是一個關于多表關聯的問題,試試看《如何優化JOIN性能》這篇文章能否幫到您uj5u.com熱心網友回復:
這個使用樹形查詢即可,起點table_a,優先(prior)a以及a的下屬,下屬的下屬,下屬的下屬 start with /connect by.轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/54008.html
標籤:開發
上一篇:【MyBatis&MyBatis-plus】分頁查詢避免兩次查詢同時回傳總數和資料
下一篇:mac怎么連oracle資料庫
