Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Two subsets to compare from
Message
From
13/01/2017 09:40:22
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Two subsets to compare from
Environment versions
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Miscellaneous
Thread ID:
01646648
Message ID:
01646648
Views:
53
I have a select such as:
SELECT Invoice.Numero
 FROM Invoice
 WHERE Invoice.NoClient IN (5,44,52,54,55,57,58,59,60,61,62,63,64,65,66,67,68,70,71,72,73,69,74,75,76,77,78,80)
Then, we could have another one such as:
SELECT Invoice.Numero
 FROM Invoice
 WHERE Invoice.NoClient2 IN (79)
I need to combine both selects into one which would return only the records where Invoice.NoClient and Invoice.NoClient2 match in both.

For example, in the example above, none would be returned.

However, if I would have this:
SELECT Invoice.Numero
 FROM Invoice
 WHERE Invoice.NoClient IN (5,44,52,54,55,57,58,59,60,61,62,63,64,65,66,67,68,70,71,72,73,69,74,75,76,77,78,80)
Then, we could have another one such as:
SELECT Invoice.Numero
 FROM Invoice
 WHERE Invoice.NoClient2 IN (5,44,79)
Then, as 5 and 44 match both, this means I would have some results.

What would be the simplest way to achieve that?
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