How can I write the best SQL query to process a WHERE IN list of 10,000 Strings
Posted on 2014-09-03
I am trying to query a DB2 Products table for a specific list of about 10,000 item #'s. The list of item's comes from another database. I am doing this in java, so the SQL query gets built dynamically, to connect to and query the DB2. But the WHERE IN list is too long and throws an error.
The error: [SQL0101] SQL statement too long or complex.
My query statement:
FROM ItemMaster m
WHERE m.mmitno IN ('AAZ4FTTBL+', 'AAZ4FTTBL+', 'AAZSHE99307', 'ABC100STOCKPOTA', 'ABC110001', 'ABC110002')
except add about 10,000 for item #'s in that WHERE list...
How do I query that many items in SQL?