我想创建一个存储过程或普通查询,其值与数组一起传递.
例:
CREATE PROCEDURE proc()
BEGIN
DECLARE cont INTEGER;
DECLARE var ARRAY;
SET cont = 0;
SET var = ("hi","hello","good",...)
WHILE cont < 12 DO
SELECT * FROM tablex
WHERE name = var[cont];
SET cont = cont + 1;
END WHILE;
END;
显然这是行不通的,但我想知道如何实现这一目标.
最佳答案
尝试没有存储的例行程序 –
原文链接:/mysql/434163.htmlSET @arr = 'hi,hello,good'; -- your array
SELECT COUNT(*) FROM tablex
WHERE FIND_IN_SET (name,@arr); -- calculate count