Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Another SQL Question
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01031642
Message ID:
01031651
Views:
13
Kevin,

Since for each Contact, you can have many phone numbers, I'd suggest ending up with a phone number cursor/view for the current contact. So, you basically run a query (or requery the view) each time you select a different contact. Assuming you have a Contact.RecordId, the query for the phone numbers could look like this:
SELECT Caption, Phone, Last ;
  FROM Phones ;
  INTO CURSOR curPhones ;
  WHERE RecordId IN ;
    (SELECT DataId ;
      FROM Links ;
      WHERE ParentId = Contact.RecordId)
HTH,
Chad

>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.
>
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Reply
Map
View

Click here to load this message in the networking platform