您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

MySQL存储过程实现split

2024/6/6 5:30:14发布27次查看
mysql存储过程实现split mysql 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; decla
mysql存储过程实现split mysql 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 ;
call procedure_split('中国,开源,社区',',');select * from splittable;
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product