码迷,mamicode.com
首页 > 移动开发 > 详细

oracle一列中的数据有多个手机号码用逗号隔开,我如何分别取出来?

时间:2014-12-03 11:51:59      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:blog   http   ar   color   sp   on   数据   div   2014   

ID      NUMBER
1 137xxxx,138xxxx
取出来成
ID NUMBER
1 137xxxx
1 138xxxx

create table test
(id int,
phone varchar2(200));
insert into test values (1,‘13811111111,13311111111,13900000000‘);
insert into test values (2,‘15811111111,15911111111,18800000000‘);


select id,c from
(with as (select id,phone c from test)
select id,substr(t.ca,instr(t.ca, ‘,‘, 1, c.lv) + 1,instr(t.ca, ‘,‘, 1, c.lv + 1) - (instr(t.ca, ‘,‘, 1, c.lv) + 1)) AS c
from (select id,‘,‘ || c || ‘,‘ AS ca,length(c || ‘,‘) - nvl(length(REPLACE(c, ‘,‘)),0) AS cnt FROM t) t,
(select LEVEL lv from dual CONNECT BY LEVEL <= 100) c where c.lv <= t.cnt) 
order by id
 
bubuko.com,布布扣

oracle一列中的数据有多个手机号码用逗号隔开,我如何分别取出来?

标签:blog   http   ar   color   sp   on   数据   div   2014   

原文地址:http://www.cnblogs.com/myjoan/p/4139348.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!