Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Search based on intersect
Message
From
16/01/2017 16:53:05
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Search based on intersect
Environment versions
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Miscellaneous
Thread ID:
01646717
Message ID:
01646717
Views:
59
I am doing a search and I would like the base result to consider only keeping those records where the found primary keys have an interception with a sub table.

Here is an example of a simulation scenario assuming we would like to search for members into which they share the same clients:
DECLARE @Parameter1 Varchar(16)
DECLARE @Parameter2 Varchar(14)

SET @Parameter1='FOURNIER%'
SET @Parameter2='FOURNIER%'

SELECT Member.Numero
FROM Member
WHERE (Member.FirstName LIKE @Parameter1 OR Member.LastName LIKE @Parameter2) AND
 EXISTS
 (
  SELECT Invoice.NoClient FROM Invoice WHERE Invoice.NoMember=Member.Numero
  INTERSECT
  SELECT Invoice.NoClient FROM Invoice WHERE Invoice.NoMember=1
 )
The problem with that syntax is that it returns members which do not intercept at the invoice level. So, the syntax has to be fine tuned to consider that. Anyone could find what is wrong?
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