对IN()的限制 [英] Limitation on IN()

查看:88
本文介绍了对IN()的限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SQL查询的IN()内部传递的值的数量限制是什么?我一直在网上浏览有关此内容的信息,但是找不到我想要的答案?

What is the limitation of number of values that are passed inside IN() in SQL query? I have been looking around about this online but not found the answer I was looking for?

推荐答案

明确声明限制为1,000,即:

When explicitly stated the limit is 1,000, i.e.:

select * from the_table where id in (1, 2, ..., 1000)

这在IN条件的文档中:

您可以在expression_list中最多指定1000个表达式.

You can specify up to 1000 expressions in expression_list.

没有明确说明时没有限制:

When not explicitly stated there is no limit:

select * from table1 where id in ( select id from table2 )

尽管有用,但通常有更好的方法将这么多或更多的值传递给SELECT.可能值得考虑一些描述或JOIN的参考表.

Though useful there are often better ways of passing this many or more values to a SELECT. It might be worth considering a reference table of some description or JOIN.

另请参阅:

  • IN vs. JOIN with large rowsets
  • How does the IN predicate work in SQL?

这篇关于对IN()的限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆