也许你要早上七点起床,晚上十二点睡觉,日复一日,踽踽独行。但只要笃定而动情地活着,即使生不逢时,你人生最坏的结果,也只是大器晚成。
call PROCEDURE_split('分享,代码,片段',',');
select * from splittable;
drop PROCEDURE if exists procedure_split;
CREATE PROCEDURE `procedure_split`(
inputstring varchar(1000),
delim char(1)
)
begin
declare strlen int DEFAULT length(inputstring);
declare last_index int DEFAULT 0;
declare cur_index int DEFAULT 1;
declare cur_char VARCHAR(200);
declare len int;
drop temporary table if exists splittable;
create TEMPORARY table splittable(
value VARCHAR(20)
) ;
WHILE(cur_index<=strlen) DO
begin
if substring(inputstring from cur_index for 1)=delim or cur_index=strlen then
set len=cur_index-last_index-1;
if cur_index=strlen then
set len=len+1;
end if;
insert into splittable(`value`)values(substring(inputstring from (last_index+1) for len));
set last_index=cur_index;
end if;
set cur_index=cur_index+1;
END;
end while;
end ;
到此这篇关于mysql存储过程如何实现split示例就介绍到这了。志在必得心坚强,女神出马鬼难当,一路拿下收视率,当今女孩当自强。更多相关mysql存储过程如何实现split示例内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!