Some where in the application there is an autogenerated query like
SELECT DISTINCT `Name`,`Number`
FROM `Table`
WHERE (`ID`=@NAZ_ID_0)
OR (`ID`=@NAZ_ID_1)
OR (`ID`=@NAZ_ID_2)
OR (`ID`=@NAZ_ID_3)
...
OR (`ID`=@NAZ_ID_690)
While executing this query ms access throws out exception “Query is too complex”. Obviously because of number of ORs which is limited to 99 in ms access.
How to change this query and avoid using this OR … OR … OR construction?
If you can influence the query creation yourself you can simply use
If you can’t control the creation of the query, but can alter it before it’s used, you can try and replace the or-s with the in-variant.
Finally, if the IN() is also too complex, you might consider creating a temporary table, fill it with the variables and use a subquery in the original query.