if it worked, what are you going to do with 2100+ records?
Nov 23, 2022
7
Level 8
Is it normal to have more than 2100 items in a whereIn clause?
I am using MS SQL and I got an error because my ->whereIn('id', $ids) has an array of more than 2100 ids in it.
If I got to this point of the WHERE IN limit - does it mean I'm doing something wrong?
If not - is there a way to split it in Laravel so that it would work? Or I will need to set it up in the DB?
Edit: It's a query to fetch data:
$data = MyModel::whereIn('id', $ids)->get();
Ty
Level 73
There is a limit on how many values can be in an IN clause, but if you use a subquery like this
SELECT *
FROM table1
WHERE some_id IN (SELECT id
FROM table2
WHERE someother_column = 'soma value');
It might be better to use EXISTS instead of in though, it coulb be faster.
1 like
Please or to participate in this conversation.