日期:2014-05-17 浏览次数:20823 次
--分割逗号
with t1 as
(
select 1 c1,'1,2,3' c2 from dual
),t2 as
(
select 1 id,'aa' na from dual union all
select 3 id,'bb' na from dual
)
select t.c2,t2.na
from
(
select distinct c1,replace(regexp_substr(c2,'[^,]+',1,level),',',' ') c2
from t1
connect by level<=length(c2)-length(replace(c2,',',''))+1
order by c1
) t left join t2 on t.c2 = t2.id
order by t.c2
c2 na
-------------------------
1 1 aa
2 2
3 3 bb