如何将一个字段里的值拆分为多个值显示出来
表 a 字段 有 ID NAME:
ID NAME 
1 AA,BB,CC
2 DD,EE
3 FF,GG,RR,QQ
想要的效果:
ID NAME
1 AA
1 BB
1 CC
2 DD
2 EE
......有大神会的没 急需谢谢了

解决方案 »

  1.   

    with tab(id,
    name) as
     (select 1, 'AA,BB,CC'
        from dual
      union all
      select 2, 'DD,EE'
        from dual
      union all
      select 3, 'FF,GG,RR,QQ' from dual)
    select tab.id, regexp_substr(tab.name || ',', '[^,]+', 1, level) name
      from tab
    connect by level <= regexp_count(tab.name || ',', '[^,]+')
           and prior id = id
           and prior dbms_random.value is not null
      

  2.   

    select distinct id,LEVEL,replace(regexp_substr(name,'[^,]+',1,level),',',' ') name
    from  test
    connect BY LEVEL<=length(name)-length(replace(name,',',''))+1
    order by id,level