zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

MySQL in语句内参数个数限制

mysql in 参数 语句 限制 个数
2023-09-14 09:02:02 时间

Oracle中,in语句中可放的最大参数个数是1000个。之前遇到超过1000的情况,可用如下语句,但如此多参数项目会低,可考虑用别的方式优化。

select * from Table where id in(xxx,xxx...) or id in(yyy,yyy,...)

 mysql中,in语句中参数个数是不限制的。不过对整段sql语句的长度有了限制(max_allowed_packet)。默认是4M

References:

https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#function_in

https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_allowed_packet