I want to know how many maximum items you can query on in mysql Query with "IN" clause. For eg: select * from student where student.name IN ("a1","a2","a3", ..... "an");
Asked
Active
Viewed 131 times
0
-
You can refer here. There is no limit to it. https://stackoverflow.com/a/4275704/10342514 – James May 23 '19 at 10:11
1 Answers
4
The number of values in IN clause is defined by the max_allowed_packet value.
https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_allowed_packet
Default Value (>= 8.0.3) 67108864
Default Value (<= 8.0.2) 4194304
But if your IN result can be generated by a query then you could replace the IN clause with an INNER JOIN

ScaisEdge
- 131,976
- 10
- 91
- 107