#如果存在searchTest存储过程则删掉
DROP PROCEDURE IF EXISTS searchTest;
#定义结束符
DELIMITER //
#创建存储过程
CREATE PROCEDURE searchTest()
BEGIN
#定义数据
SET @a = ‘‘;
SET @b = ‘‘;
SET @c = ‘‘;
#获取数组长度
SET @num = LENGTH(@a) - LENGTH(REPLACE(@a,‘,‘,‘‘)) + 1;
SET @i = 1;
#循环取数组内容
WHILE(@i <= @num) DO
SET @tempa = SUBSTRING_INDEX(@a,‘,‘,@i);
SET @tempb = SUBSTRING_INDEX(@b,‘,‘,@i);
SET @tempc = SUBSTRING_INDEX(@c,‘,‘,@i);
SELECT * from t_product_info where id = SUBSTRING_INDEX(@tempa,‘,‘,-1) and id = SUBSTRING_INDEX(@tempb,‘,‘,-1) and id = SUBSTRING_INDEX(@tempc,‘,‘,-1)
SET @i = @i + 1;
END WHILE;
END//
#调用存储过程
CALL searchTest();
#删除存储过程
DROP PROCEDURE IF EXISTS searchTest;