首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

oracle 瓜分字符串 regexp_substr

2012-11-12 
oracle 分割字符串 regexp_substr表数据如下:idsid3,4,6523,24,26,2728想要使用一个sql,将ids拆分后查询到

oracle 分割字符串 regexp_substr
表数据如下:
ids id  
3,4,6 5
23,24,26,27 28

想要使用一个sql,将ids拆分后查询到如下记录。请教如何实现。
ids id
3 5
4 5
6 5
23 28
24 28
26 28
27 28

[解决办法]

SQL code
select ids, id from(  select regexp_substr(ids, '[^,]+',1,lvl) ids, lvl, id from t,  (select level lvl from dual connect by  level < =(select max(length(regexp_replace(ids,'[^,]','')))+1 max_tokens from t))) where ids is not null order by id, lvl; 

热点排行