Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Search based on intersect
Message
De
16/01/2017 16:53:05
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Search based on intersect
Versions des environnements
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Divers
Thread ID:
01646717
Message ID:
01646717
Vues:
60
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform