Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Instead of OR in WHERE clause
Message
 
 
To
03/02/2014 23:00:12
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01593065
Message ID:
01593076
Views:
26
>>This query
>>
>>select * from myTable where Condition1 OR Condition2
>>
>>is the same as
>>
>>select * from myTable where Condition1
>>UNION
>>select * from myTable where Condition2
>
>Is it really faster?
>
>Also, we need to consider that the select line is very big. So, if I have 1000 primary keys, I would have to repeat that line 1000 times.

No, not necessary. Most likely it will perform the same, but only tests will tell for sure. I saw UNION suggested by Erland Sommarskog on a few occasions.

I am also not sure about your 1000 primary keys - why is it relevant?

In any case, you asked what can be used instead of OR and I gave you the answer.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform