MySQL IN constraint

Hey, I need to use the IN clause in my MySQL statement with a large set of identifiers.

Example

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

Is there a limit if elements that an IN operator can have?

+55
mysql condition
Nov 25 2018-10-11T00:
source share
3 answers

No, there is no instruction about the IN function :

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

+80
Nov 25 '10 at 9:51
source share

As far as I know in mysql, there are no restrictions for elements in an IN statement.

In the oracle, in the expression IN there is a limit of 1000 elements.

But with more elements in IN , the performance of your query will slow if the index is not indexed.

+15
Nov 25 '10 at 9:50
source share

enter image description here

1073741824 This is the limit specified in Mysql docs.

0
Apr 11 '19 at 6:16
source share



All Articles