Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another SQL Question
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01031642
Message ID:
01031691
Vues:
10
Close. The first phone record was duplicated for the first 2 clients.
Contact 'Sally Silly' only has 1 phone record, '4545454545':
00000001 Sally          Silly          7609416682
00000000 Jack           Johnson        7609416682
00000000 Jack           Johnson        8888888888
00000000 Jack           Johnson        5555555555
00000001 Sally          Silly          4545454545
Cetin's code did the job:
select Contacts.*, Phones.Phone ;
  from Contacts ;
  left join links on Contacts.RecordId = Links.ParentID ;
       and Links.Key == 'phone' ;
  left join Phones on Links.DataID = Phones.RecordID;
  INTO CURSOR Results2
Thanks Sergey






>Try
SELECT Contacts.*, Phones.Phone ;
>  FROM Contacts ;
>  JOIN Links ON Links.ParentId  = Contacts.RecordId ;
>  JOIN Phones ON Phones.RecordId  = Links.DataId
>
>
>>I have a Contacts table. I also have a Phones table. They are related
>>through a Links table. I would like to pull the client record, and have
>>all the phone numbers on the client record.
>>
>>Anyone?
>>

>>
>>The relationships:
>>
>>Contacts
>>   |
>>   -< Links
>>       |
>>       -< Phones
>>
>>
>>
>>The structures:
>>
>>Contacts
>>RecordId  FName   LName
>>-----------------------------------------------------
>>00000001  Joe     Smith
>>
>>Links
>>RecordId  ParentId  DataId    Key
>>-----------------------------------------------------
>>AAAAAAAA  00000001  ZZZZZZZZ  "phone"
>>AAAAAAAA  00000001  QQQQQQQQ  "phone"
>>AAAAAAAA  00000001  FFFFFFFF  "phone"
>>
>>
>>Phones
>>RecordId  Caption         Phone       Last
>>-----------------------------------------------------
>>ZZZZZZZZ  Home            8005551212  .T.
>>QQQQQQQQ  Business        8001212555  .T.
>>FFFFFFFF  Cell            8885544877  .T.
>>
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform