oracle 逗号分割,列转行,行转列

with a as (select 'ABC,AA,AD,ABD,JI,CC,ALSKD,ALDKDJ' id from dual)
select regexp_substr(id,'[^,]+',1,rownum) id from a
connect by rownum <= length(regexp_replace(id,'[^,]+'))



drop table ZDL1;

CREATE TABLE ZDL1
(
      clientid VARCHAR(40),
      IDS VARCHAR(400)
);

insert into zdl1 values('123','ABC,AA,AD,ABD,JI,CC,ALSKD,ALDKDJ,');

select *
from
(
  with a as (select distinct clientid,ids from ZDL1)
  select clientid,regexp_substr(ids,'[^,]+',1,rownum) id
  from a
  connect by rownum <= length(regexp_replace(ids,'[^,]+'))
) t;



参照:
https://www.cnblogs.com/gdzhong/p/4726315.html?tvd

终极方案:参照连接:https://blog.csdn.net/yang_da_da/article/details/99726086


原文地址:https://www.cnblogs.com/dianli_jingjing/p/7987919.html