SELECT statement Condition limit?

Is there a limit to the number of conditions I can put in the WHERE clause of a SELECT statement?

I am recieveing a list of values (UIDS actually) and I need to dynamically create a SQL Statement. My only concern is if there is a limit to the number of conditions 'OR' in the Statement, the list could be anywhere from 1-1000+ values. Is it safe to construct the statement this large? Or I do I need to run individual queries, or batches with a max number. Any advise on the optimal way to do this would be appreciated.



  • I did the problem like you. I tried create statement with about 20,000 OR values and IN also. The SQL statement still run, but runtime is very long.

    I think that if we must to do this with a large number of checked value, so we should consider to choose another way.

    In my case, I tried to convert series of values to many ranges and used BETWEEN instead of OR.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion