select a as fromuser,b as touser from dual
union all
select b,c from dual
union all
select e,c from dual
union all
select d,b from dual已知a,找到与其有关系的所有人
求大神??
union all
select b,c from dual
union all
select e,c from dual
union all
select d,b from dual已知a,找到与其有关系的所有人
求大神??
select 'a' as f,'b' as t from dual
union all
.
.
.
搜索层次查询
with t1 as(
select 'a' as fromuser,'b' as touser from dual
union all
select 'b','c' from dual
union all
select 'e','c' from dual
union all
select 'd','b' from dual
)select * from t1;
我知道start with connce by nocycle 可以实现,但是要反转union all 才能实现。
with tt as
(select f,t
from
(select 'a' f ,'b' t from dual
union all
select 'b' f, 'c' t from dual
)
union all
select t,f
from
(select 'a' f ,'b' t from dual
union all
select 'b' f, 'c' t from dual
)
)
select tt.f,tt.t
from tt
start with tt.f='a'
connect by nocycle prior tt.t=tt.f这个写法有点会出现重复,有没有便利点的写法?