Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
3 Table SQL Join
Message
 
 
À
07/12/1999 19:05:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00300033
Message ID:
00300336
Vues:
28
>OOPS! Please note the addition of the Filter columns for TableB and TableC.
>
>The following code returns 2 rows, but I desire 5 rows (one row per row of TableA).
>
>
select TableA.*, TableB.*, TableC.*;
> from TableA ;
> Left Outer Join TableB ;
> on TableA.Ident = TableB.Ident ;
> and TableA.FKey = TableB.FKey ;
> Left Outer Join TableC ;
> on TableA.Ident = TableC.Ident ;
> where TableB.FiltB = 1 ;
> and TableC.FiltC = 1 ;
> group by TableA.Ident
>
If you remove the GROUP BY you will get the 3 matching rows from TableA. Because you are applying the filter where FiltB = 1 and FiltC = 1, you are never going to get all 5 records from A. Your query is returning exactly what you are asking for. If you want all 5 records you have to remove the filter clause and put in GROUP BY TableA.Ident, TableA.FKey.
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform