Hi
Can anyone tell me? If we execute two queries one with OR and Other one with IN then which one will be faster?
Thanks in Advance
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Amit ChoudharyPosted Aug 18, 2011, 2:34 AM
if you have a set of values then don't hesitate to use IN clause cause it will make your query simpler and won't take extra time to filter the result for the value set.
Jiteendra SampathiraoPosted Aug 18, 2011, 12:45 AM
The SQL IN clause allows you to specify discrete values in your SQL WHERE search criteria.
OR clause:
The OR operator displays a record if either the first condition or the second condition is true.
ex: SELECT some_x,some_y,some_z FROM some_table
WHERE Name='some_name1' OR Name='some_name2'
In clause is faster than OR clause...bacause OR clause returns the value after checking two conditions, where as in In clause it checks a column with some values..like
Ex: select something from some_table where some_column IN (some_value1, some_value2);
i hope it help you......