Please tell me from experience with using the "IN clause" in a MySQL query is considered to be too large of a list to push through to be considered good practice?
Example scenario is I have a string of user ID numbers that I will pull from a cache, it can range from anywhere from 1 number all the way up to being 5,000 numbers in this list and I will use a mysql query with this list like this example;
SELECT column FROM table
WHERE userid
IN ( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 )
Can you give me your thoughts on this issue please?
The number of values in the IN Caluse can vary anywhere from 0 to thousands.
In MySQL the LIMIT clause is used with the SELECT statement to restrict the number of rows in the result set. The Limit Clause accepts one or two arguments which are offset and count. The value of both the parameters can be zero or positive integers.
The MySQL IN Operator The IN operator allows you to specify multiple values in a WHERE clause. The IN operator is a shorthand for multiple OR conditions.
MySQL LENGTH() Function The LENGTH() function returns the length of a string (in bytes).
It should be noted that some databases have limits on the number of entries within an IN clause - Oracle versions <= 10 are limited to 1000. I'm not sure about v11.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With