Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Search based on intersect
Message
De
17/01/2017 02:44:28
 
 
À
16/01/2017 16:53:05
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:
01646717
Message ID:
01646724
Vues:
38
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform