Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WHERE IN syntax for Exist/Not Exist
Message
 
 
À
29/01/2017 09:47:19
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Divers
Thread ID:
01647092
Message ID:
01647113
Vues:
35
>>Most times when people use IN, they use it with a subquery that isn't written as a correlated subquery.
>>
>>Again, what you have works. (Admittedly, when I read it, I wondered if it would generate an error, because I assumed...dangerous world....that IN would not work with subqueries that referenced a table from the outer query).
>>
>>If you were worried about NULL values in the Province table, then EXISTS might be better (EXISTS certainly works better if you have to search on multiple columns)
>>
>>Maybe Naomi or Sergey or someone else who has run into this can jump in - admittedly this was the first time I'd ever seen an IN with a subquery written as a correlated subquery. It seemed a bit odd and I was actually surprised it worked. But maybe I'm missing something.
>
>Exists might have been a better choice actually. Thanks

What I learned is that IN with a subquery is always very poor performance and should never be done. Always use Exists instead.

http://stackoverflow.com/questions/2065329/sql-server-in-vs-exists-performance
Christian Isberner
Software Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform