Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select joining same table multiple times
Message
De
05/07/2000 23:16:33
Gavin Reid
L & M Marketing Pty Ltd
Frenchs Forest, Australie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00388673
Message ID:
00388677
Vues:
8
Hi Cathi,

   You could try opening the customer table multiple times.

E.g.

   SELECT contract.id, c1.lastname, c2.lastname, c3.lastname ;
        , c4.lastname, c5.lastname, c6.lastname
       FROM contract, customer c1, customer c2, customer c3 ;
          , customer c4, customer c5, customer c6 ;
       WHERE c1.custid = contract.custid1 ;
       AND   c2.custid = contract.custid2 ;
       AND   c3.custid = contract.custid3 ;
       AND   c4.custid = contract.custid4 ;
       AND   c5.custid = contract.custid5 ;
       AND   c6.custid = contract.custid6 ;
   INTO TABLE blahblah

This would only work though if all six id fields had values in them.

Hope this helps
Gavin...
>I have a table that has six fields which hold IDs from the same table. Each field can have different IDs. Example:
>
>Contract Table:
>
>ContractID
>CustID1
>CustID2
>CustID3
>CustID4
>CustID5
>CustID6
>
>
>Customer Table:
>
>CustID
>First Name
>Last Name
>
>In the Contract table the CustIDx fields are all referencing the same Customer table. However, CustID1 will be different than CustID2, etc.
>
>I need to create a Select statement that ends up with the following:
>
>ContractID, Last Name (of CustID1), Last Name (of CustID2), Last Name (of CustID3), etc. FROM Contract
>
>How do I write this select statement since the information is being pulled from the same Customer table?
>
>Thanks for any help.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform