MySQL IN 条件限制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4275640/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL IN condition limit
提问by xpepermint
Hey, I have to use IN condition in my MySQL statement with a large set of ids.
嘿,我必须在具有大量 ID 的 MySQL 语句中使用 IN 条件。
Example
例子
SELECT * FROM users WHERE id IN (1,2,3,4...100000)
Is there a limit if items the IN statement can have?
IN语句可以包含的项目是否有限制?
回答by Progman
No there isn't, check the manual about the IN function:
The number of values in the
IN
list is only limited by the max_allowed_packetvalue.
IN
列表中值的数量仅受max_allowed_packet值的限制。
回答by Sachin Shanbhag
As far as I know in mysql, there is no limit for items in the IN
statement.
据我所知在mysql中,IN
语句中的项没有限制。
In oracle altough, there is a limit of 1000 items in the IN
statement.
在 oracle 中,IN
语句中的条目限制为 1000 。
But more the items in IN
, your query performance will slow down unless that column is indexed.
但是 中的项目越多IN
,除非该列被索引,否则您的查询性能会变慢。