国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

mysql存儲過程實現split示例

2024-07-24 13:05:47
字體:
來源:轉載
供稿:網友

復制代碼 代碼如下:


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 ;

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 望奎县| 怀柔区| 东乌珠穆沁旗| 南开区| 灯塔市| 虹口区| 蓬溪县| 金乡县| 遂川县| 西昌市| 琼结县| 商城县| 武城县| 泰安市| 基隆市| 保定市| 大同县| 裕民县| 新昌县| 玛纳斯县| 张家口市| 徐闻县| 勃利县| 会同县| 壶关县| 海兴县| 镇江市| 扶绥县| 津南区| 八宿县| 新余市| 平顺县| 滦平县| 梧州市| 南陵县| 镇巴县| 建昌县| 盘山县| 屏南县| 阳江市| 宁明县|