oracle 分割字符串 regexp_substr

lxw2100 2012-10-24 12:09:21
表数据如下:
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
...全文
282 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxw2100 2012-10-24
  • 打赏
  • 举报
回复
问题已解决,非常感谢。
fw0124 2012-10-24
  • 打赏
  • 举报
回复
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;

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧