Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Instead of OR in WHERE clause
Message
De
04/02/2014 10:43:22
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
04/02/2014 10:39:41
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:
01593120
Vues:
26
>>SELECT * FROM TABLE WHERE FIELD IN (1,2,3,4,5,7,8,9). What number is missing? How long does it take you to determine one is missing? That's just single digit ID's. Why should you have to be concerned with that?
>
>If I only have a few keys, why would I use a route to create a temporary SQL Server table and negotiate with that with a IN table clause?
>
>>select * from table where field in (select key from userschoices) is much, much cleaner. It provides far more than 32000 keys. If I understand the intent, the user can select many ids - whether you concatenate them into a string or add them to a table - is little difference to the user. But using a single technique - adding them to a table and not trying to decide if you want to use IN in one case and a temp table in another is also much easier on you.
>
>Yes, the syntax might be cleaner but it requires the setup of a temporary table, which is overkill in such situations.

I'm sorry. Again I disagree. That's like saying it's easier to use a screwdriver to put in a drywall screw because it is overkill to setup the electric drill. That is what is meant by premature optimization. You are attempting to use the "optimal" approach for either situation when one will do it all.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform