Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WHERE IN syntax for Exist/Not Exist
Message
 
À
28/01/2017 12:12:14
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:
01647093
Vues:
56
This message has been marked as the solution to the initial question of the thread.
Hi Michael,
SELECT Client.Numero, Province.Numero AS Province_Numero
 FROM Client OUTER APPLY (SELECT Province.Numero FROM Province WHERE Province.Numero=Client.NoProvince AND Province.Active=1) Province

SELECT Client.Numero, 
             (SELECT Province.Numero FROM Province WHERE Province.Numero=Client.NoProvince AND Province.Active=1) AS Province_Numero
 FROM Client
MartinaJ


>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?
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform