MySQL没有Split 函数,需要自己定义,以下是几个自定义的split函数,MySQL里的Split用法。
CREATE PROCEDURE sp_split(in words varchar(2000),in regex varchar(20))
BEGIN
CREATE TEMPORARY TABLE IF NOT EXISTS temp_key_split
(
key_words varchar(20)
);
DELETE FROM temp_key_split;
while(instr(words,regex)<>0) DO
INSERT temp_key_split(key_words) VALUES (substring(words,1,instr(words,regex)-1));
set words = INSERT(words,1,instr(words,regex),'');
END WHILE;
INSERT temp_key_split(key_words) VALUES (words);
END;
MyBatis中操作存储过程
call sp_split((
SELECT GROUP_CONCAT(seo_keywords) FROM shopping_goods WHERE seo_keywords LIKE CONCAT(CONCAT('%', #{goods_key}),'%')
), ',');
- 本文地址:https://www.linuxprobe.com/mysql-implements-split.html
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.