For help: the data in a table on the left in the picture, want to get the right results, how SQL implementation?
CodePudding user response:
Logical relationship didn't readCodePudding user response:
with tab1 as (
The select table_id1, table_id2
The from table_a
Start with table_id1='TABLE_A'
Connect by the prior table_id2=table_id1
)
The select table_id1 from tab1
The union
The select table_id2 from tab1
The order by table_id1
;
CodePudding user response:
The select COLUMN1
The from test_insert3
Start with COLUMN1='T_A'
Connect by the prior COLUMN2=COLUMN1
The UNION
The select COLUMN2
The from test_insert3
Start with COLUMN1='T_A'
Connect by the prior COLUMN2=COLUMN1
CodePudding user response:
select dept_name from (select t.d ept_id, t.d ept_name, t.d ept_code, t.p ar_dept_id, level
The from SYS_DEPT t
Start with t.d ept_id='40288 ac45a3c1e8b015a3c28b4ae01d6'
Connect by the prior t.d ept_id=t.p ar_dept_id
The order by level, t.d ept_code) order by level
CodePudding user response:
I don't see the result is how to return a responsibility? Didn't see the tree structureCodePudding user response:
Select DISTINCT TABLE_ID1 FROM TABLE_AThe UNION
Select DISTINCT TABLE_ID2 FROM TABLE_A
CodePudding user response:
This is a problem about the link table more, give it a try "how to optimize performance of the JOIN" this article can help youCodePudding user response:
The use of tree query, table_a starting point, the first (the prior) a and a subordinate, subsidiary of subordinates, subordinate subsidiary start with/connect by.