sql拆分一个字段里面逗号分割的数据

sql把一个字段里面用逗号分割的数据解析成多行数据

with
base as (select level lv from dual connect by level <= 100) ,
info as (select id,needsplit,(length(needsplit) - length(replace(needsplit,’,’,’’)) + 1) as cnt
from xxx )
select id, regexp_substr(b.needsplit, ‘[^,]+’,1,a.lv) as split
from base a, info b
where a.lv <= b.cnt;

你可能感兴趣的:(oracle,sql)