oracle一列中的数据有多个手机号码用逗号隔开,我如何分别取出来?
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
t
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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。