Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Indirect join
Message
From
30/11/2006 18:38:49
 
 
To
30/11/2006 18:30:23
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
01171237
Message ID:
01173936
Views:
10
Twas my thought you might like to see the solution in its final form.

>Don,
>Why are you CCing? I already know what I have written:)
>Cetin
>
>>Well here's the solution. Thanks Sergey.
>>
>>lcSites = addbs(fileloc) + 'bluebook\sites'
>>lcERs = addbs(fileloc) + 'bluebook\ers'
>>lcCEO1 = addbs(fileloc) + 'bluebook\people'
>>lcTC1 = addbs(fileloc) + 'bluebook\people'
>>lcTC2 = addbs(fileloc) + 'bluebook\people'
>>
>>select * , ers.name as 'ername', tc1.fullname as 'tc1name', ;
>>	tc2.fullname as 'tc2name', ceo1.fullname as 'ceo1name' ;
>>	from trpcontacts!Sites ;
>>	left outer join (lcERs) ers on sites.er = ers.er_id ;
>>	left outer join (lcTC1) tc1 on sites.tc1 = tc1.person_id ;
>>	left outer join (lcTC2) tc2 on sites.tc2 = tc2.person_id ;
>>	left outer join (lcCEO1) ceo1 on sites.ceo1 = ceo1.person_id ;
>>	into cursor crsTempBlueBook
>>
>>
>>
>>
>>>Use table aliases
>>>select sites.*, ers.name, tc1.name, tc2.name, ceo1.name ;
>>>   from (lcSites) sites ;
>>>     left join (lcERs) ers on sites.er = ers.er_id ;
>>>     ...
>>>     left join (lcCEO1) ceo1 on sites.ceo1 = ceo1.person_id
>>>
>>>
>>>>Well I solved this problem using Vladimir's suggestion. Thanks Vladimir.
>>>>But now I have a bigger question.
>>>>If the main table has fields containing pointers to data in other tables IE sites.er contains an er_id from table er, then
>>>>
>>>>
>>>>lcSites = addbs(fileloc) + 'bluebook\sites'
>>>>lcERs = addbs(fileloc) + 'bluebook\ers'
>>>>
>>>>select * , ers.name ;
>>>>from (lcSites) ;
>>>>left outer join ers on sites.er = ers.er_id ;
>>>>into cursor crsTempBlueBook
>>>>
>>>>will produce a cursor containing the name of the er taken from the er lookup table. But how do you structure a situation where there are several of these lookups in the main table? As in:
>>>>
>>>>lcSites = addbs(fileloc) + 'bluebook\sites'
>>>>lcERs = addbs(fileloc) + 'bluebook\ers'
>>>>lcCEO1 = addbs(fileloc) + 'bluebook\people'
>>>>lcTC1 = addbs(fileloc) + 'bluebook\people'
>>>>lcTC2 = addbs(fileloc) + 'bluebook\people'
>>>>
>>>>** yielding something like
>>>>select * , ers.name, tc1.name, tc2.name, ceo1.name ;
>>>>   from (lcSites) ;
>>>>   (lcERs) as ers ;
>>>>   (lcCEO1) as ceo1 ;
>>>>   left outer join (lcERs) on sites.er = ers.er_id ;
>>>>   left outer join (lcCEO1) on sites.ceo1 = ceo1.person_id
>>>>
>>>>etc.
>>>>
>>>>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform