Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Instead of OR in WHERE clause
Message
 
 
À
03/02/2014 23:00:12
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01593065
Message ID:
01593076
Vues:
27
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform