Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WHERE IN syntax for Exist/Not Exist
Message
De
28/01/2017 12:12:14
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
WHERE IN syntax for Exist/Not Exist
Versions des environnements
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Divers
Thread ID:
01647092
Message ID:
01647092
Vues:
63
I have a select to do to retrieve records from a table where one of the where clause field primary key of a field exists in a sub table with its related condition.

So, we would usually do this like this:
SELECT Client.Numero
 FROM Client
 WHERE Client.NoProvince IN (SELECT Province.Numero FROM Province WHERE Client.NoProvince=Province.Numero AND Province.Active=1)
Now, I need to expand that to support the possibility that the client table might not always have a province value. If that is the case, I need to collect that record as well.

So, basically, I would like to avoid doing a UNION. Would there be a way with such select to add support for such need?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform