MySQL IN 条件限制

2021-11-20 00:00:00 conditional-statements mysql

嘿,我必须在包含大量 ID 的 MySQL 语句中使用 IN 条件.

Hey, I have to use IN condition in my MySQL statement with a large set of ids.

示例

SELECT * FROM users WHERE id IN (1,2,3,4...100000)

IN 语句可以包含的项目是否有限制?

Is there a limit if items the IN statement can have?

推荐答案

不,没有,检查 关于 IN 函数的手册:

IN 列表中的值数量仅受 max_allowed_pa​​cket 值.

The number of values in the IN list is only limited by the max_allowed_packet value.

相关文章