Akash Jain
Akash Jain

Reputation: 277

Maximum Limit For IN Query in Mysql

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");

Upvotes: 0

Views: 322

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133360

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

Upvotes: 4

Related Questions