Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One Parent - Two Child
Message
From
24/08/2000 13:38:29
 
 
To
24/08/2000 13:29:12
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00408860
Message ID:
00408877
Views:
12
>>Having some trouble with Select statement for following situation :
>>
>>TableA TableB TableC
>>priAid I Primary PriBid I Primary PriCid I Primary
>>priBid I Fieldb2 C Fieldc2 C
>>PriCid I Fieldb3 C Fieldc3 C
>>Fielda4 C
>>Fielda5 C
>>
>>Table A has one-to-one relation to B ( priBid ), Table A has one-to-one relation to C ( priCid )
>>
>>I need to select tableA.Fielda4,tableB.Field2b,tableC.fieldc2 into a single record. For example if the search criteria was WHERE tableA.priAid = 1
>>
>>The problem I am running into is the JOIN, I tried creating view to see example SQL code but got error saying can not have one parent to more than one child
>>
>>Thanks !! CB
>
>Sorry format did not stay the same
>TableA
>priAid I Primary
>priBid I
>PriCid I
>Fielda4 C
>Fielda5 C
>
>TableB
>PriBid I Primary
>Fieldb2 C
>Fieldb3 C
>
>TableC
>PriCid I Primary
>Fieldc2 C
>Fieldc3 C

(copied From my other reply - just to keep it all together...)
Try putting tableA in the middle:

select tableA.Fielda4,tableB.Field2b,tableC.fieldc2 ;
from tableB join tableA ;
join tableC ;
on tableA.priAid = tableC.priAid ;
on tableB.priAid = tableA.priAid ;
where tableA.priAid = nPrimaryKeyVariable


Also, don't put the keys to tableB and tableC in TableA since tableA is the parent. Rather, put TableA's key in tableB and tableC. IOW,

TableA
priAid I Primary
Fielda4 C
Fielda5 C

TableB
PriBid I Primary
priAid I Regular index
Fieldb2 C
Fieldb3 C

TableC
PriCid I Primary
priAid I Regular index
Fieldc2 C
Fieldc3 C
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform