create table ewen_testsplit
(name varchar(25) null,
id varchar(255) null
)
;
create table numbers
(
id int
)
;
insert into numbers
select 1
union all
select 2
union all
select 3
union all
select 4
union all
select 5
union all
select 6
union all
select 7
union all
select 8
union all
select 9
union all
select 10
union all
select 11
union all
select 12
union all
select 13
union all
select 14
union all
select 15
insert into ewen_testsplit values
('ewen','1,2,3,4')
select * from ewen_testsplit
select name, SPLIT_PART(id,',',1) from ewen_testsplit
select name, SPLIT_PART(id,',',2) from ewen_testsplit
select name, SPLIT_PART(id,',',3) from ewen_testsplit
select name, SPLIT_PART(id,',',4) from ewen_testsplit
select name, SPLIT_PART(id,',',5) from ewen_testsplit
select name, SPLIT_PART(s.id,',',n.id) ,regexp_count(s.id, ',')
from ewen_testsplit s inner join numbers n on n.id<regexp_count(s.id, ',')+2
网友评论