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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 17:48:23  来源:igfitidea点击:

MySQL IN condition limit

mysqlconditional-statements

提问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:

不,没有,请查看有关 IN 功能手册

The number of values in the INlist is only limited by the max_allowed_packetvalue.

IN列表中值的数量仅受max_allowed_pa​​cket值的限制。

回答by Sachin Shanbhag

As far as I know in mysql, there is no limit for items in the INstatement.

据我所知在mysql中,IN语句中的项没有限制。

In oracle altough, there is a limit of 1000 items in the INstatement.

在 oracle 中,IN语句中的条目限制为 1000 。

But more the items in IN, your query performance will slow down unless that column is indexed.

但是 中的项目越多IN,除非该列被索引,否则您的查询性能会变慢。

回答by praveen

enter image description here

在此处输入图片说明

1073741824 This is the limit given in Mysql docs

1073741824 这是 Mysql 文档中给出的限制