复制代码 代码如下:
select * from table_name t where t.field1 in (1,2,3,4,...);
复制代码 代码如下:
select * from table_name t where find_in_set(t.field1,'1,2,3,4');
复制代码 代码如下:
DROP PROCEDURE IF EXISTS photography.Proc_Test;
CREATE PROCEDURE photography.`Proc_Test`(param1 varchar(1000))
BEGIN
set @id = param1;
set @sel = 'select * from access_record t where t.ID in (';
set @sel_2 = ')';
set @sentence = concat(@sel,@id,@sel_2); -- 连接字符串生成要执行的SQL语句
prepare stmt from @sentence; -- 预编释一下。 “stmt”预编释变量的名称,
execute stmt; -- 执行SQL语句
deallocate prepare stmt; -- 释放资源
END;
新闻热点
疑难解答