导读 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中操作存储过程

<select id="callStoredProcedure" parameterType="pd" statementType="CALLABLE">
	call sp_split((
		SELECT GROUP_CONCAT(seo_keywords) FROM shopping_goods WHERE seo_keywords LIKE CONCAT(CONCAT('%', #{goods_key}),'%')
	), ',');
</select>

原文来自:http://blog.csdn.net/xhaimail/article/details/79408526

本文地址:http://www.arianebastin.com/mysql-implements-split.html编辑:薛鹏旭,审核员:逄增宝

Linux命令大全:http://www.linuxcool.com/