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
Faster query between OR and IN
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted Aug 17, 2011, 8:45 PM EDT
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......
Amit ChoudharyRank #145 · 15.8K reputationPosted Aug 17, 2011, 10:34 PM EDT
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.