Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Search based on intersect
Message
From
17/01/2017 02:44:28
 
 
To
16/01/2017 16:53:05
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Miscellaneous
Thread ID:
01646717
Message ID:
01646724
Views:
37
>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?

It's not very clear - at all, you restrict the result to Member number = 1

Don't think you need the INTERSECT and the SELECT just after
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform