日期:2014-05-16  浏览次数:20645 次

求mysql实现split的方法
参数变量 
string 值是 1,2,3,4,5,6,....n  

传到存储过程里实现

loop读出
1 执行1相关sql语句
2 执行2相关sql语句
3 执行3相关sql语句
4 执行4相关sql语句
5 执行5相关sql语句
6... 执行6相关sql语句
n 执行n相关sql语句


------解决方案--------------------
There are two functions can satisfy your demand.
SQL code

DELIMITER $$

CREATE DEFINER=`root`@`%` FUNCTION `func_get_split_string_total`(
f_string varchar(1000),f_delimiter varchar(5)
) RETURNS int(11)
BEGIN
  return 1+(length(f_string) - length(replace(f_string,f_delimiter,'')));
END$$

DELIMITER ;