Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WHERE IN syntax for Exist/Not Exist
Message
From
28/01/2017 12:12:14
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
WHERE IN syntax for Exist/Not Exist
Environment versions
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Miscellaneous
Thread ID:
01647092
Message ID:
01647092
Views:
62
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
Next
Reply
Map
View

Click here to load this message in the networking platform