I have about 273 items in a MySQL IN() list, and I believe this is causing a problem with getting all of the information I need for these items, and not sure how to change this query to just 1 or atleast less than 273 individual queries. Basically I have a list of string names that I need to query against and get the Name
and ListID
where Name is inside of a 273 count array:
$result = $wpdb->get_results('
SELECT Name, ListID
FROM ' . $wpdb->prefix . 'quickbook_items
WHERE Name IN ("' . implode('", "', array_map('addslashes', $part_names)) . '")
ORDER BY NULL', ARRAY_A);
I feel like I have read somewhere that using queries in Wordpress with IN
could be problematic if the list is too large, in that Wordpress will not grab all data. But I don't remember if this is a Wordpress $wpdb
limitation or a MySQL limitation. In any case, I am NOT getting all of the 273 rows returned, so I'm really not sure how to perform this query, while keeping db hits lower than 273 times (which would occur if I put the query inside of a loop, looping through $part_names
.
Anyone have a suggestion on how to query Name and ListID from the quickbook_items
table as shown above? Could really use some help here, or if there is a way to not have a limit of characters on a query set, to achieve this?