Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
3 Table SQL Join
Message
 
 
À
07/12/1999 17:03:19
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:
00300052
Vues:
28
>
>For the tables described below:
>
>    Table A (ForeignKey, Identifier, DataA)
>        : Primary Key = ForeignKey+Identifier
>
>    Table B (ForeignKey, Identifier, Filter, DataB)
>        : Primary Key = ForeignKey+Identifier
>
>    Table C (Identifier, Filter, DataC)
>        : Primary Key = Identifier
>
>Desired query result:
>
>    For ForeignKey = a single value and Filter = a single value
>
>    Result Table R (Identifier, DataB, DataC)
>
>    Where there is exactly one row for each Identifier in Table A,
>    even if there are no matching rows in Table B or Table C.
>
>What is the SQL Select Statement using SQL 95 Join syntax to generate
>the desired result?
>
>
You would do a left join on Tables B and C.

... from TableA ;
Left Join TableB ;
on TableA.Identifier = TableB.Identifier ;
Left Join TableC ;
on TableA.Identifier = TableC.Identifier ;
group by TableA.Identifier

The GROUP BY is needed to return exactly 1 row per identifier in TableA
Mark McCasland
Midlothian, TX USA
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform