【发布时间】:2017-03-28 21:23:16
【问题描述】:
我有一个 mysql 存储过程,它接受一个字符串,它是一个整数列表。我想使用 msql ,,in (),, 搜索这个字符串。
示例: 字符串参数 = "1,2,3,4,5,6";
select * from table where table.id in (parameter);
【问题讨论】:
标签: mysql sql string stored-procedures int
我有一个 mysql 存储过程,它接受一个字符串,它是一个整数列表。我想使用 msql ,,in (),, 搜索这个字符串。
示例: 字符串参数 = "1,2,3,4,5,6";
select * from table where table.id in (parameter);
【问题讨论】:
标签: mysql sql string stored-procedures int
我猜你可以使用find_in_set:
select *
from table
where find_in_set(id, parameter);
但是,请注意,以上将限制优化器在 id 列上使用索引(如果有的话)。
如果可以,在检查应用程序中的 SQL 注入等之后,将其连接到 SQL,这样会更好:
"select * from table where id in (" + parameter + ")"
并使用它来执行。
【讨论】: