Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
A question on how to link to another table using SELECT?
Message
From
19/10/2000 10:27:05
 
 
To
18/10/2000 11:42:37
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00430870
Message ID:
00431447
Views:
9
>>Jim, I can not use a LEFT JOIN cause table2 is a child and has many part_numbers of the same and table1 is the parent with unique part_numbers.
>>example....
>>table1 value
>>part_number 123
>>
>>table2 value
>>part_number 123
>>part_number 123
>>Part_number 123
>>any other ideas?
>
>SELECT Table1.Part_number, Table2.St, States.State_name ;
> FROM Table1 LEFT JOIN Table2 ON Table1.Part_number = Table2.Part_number ;
> LEFT JOIN States ON Table2.St = States.St ;
> INTO CURSOR MyResult ;
> GROUP BY Table1.Part_number, Table2.St, States.State_name
>
>Please read under SELECT-SQL in the docs and see the difference/similarities between SELECT DISTINCT and GROUP BY. There are extensive discussions of things like this in Joe Celko's SQL For Smarties, Second Edition, which is what I have studied to learn SQL where the FoxPro docs didn't tell me enough.
>
>As programmers, we ALL work with "other people's code" on a daily basis. Those of us who volunteer to help others here volunteer to help them with problems WE didn't create. Part of what makes a good programmer is learning how to figure out OPC and refine it to make it faster or more efficient or easier to understand and maintain.
--------------
Good Morning Cindy...
Group by works…....thanks....
The problem was that the part_numbes were not DISTNCT,
and there were needed values in the same part_number record.
Example….
Table1 Value Value
Part_number 123 25 – (needed value)
Part_number 123 50 – (needed value)

The problem could be fixed in two ways…
Way 1….coded extra step and use GROUP BY before running the result query.
Way 2… in query statement, call a function that gets the DESCRIPTION…example
SELECT ………….get_desc(arg) AS fld_description…..

Function get_desc
Parm part_no
find by part no
Return fld_description

Thanks all for your help…..
Robert Keith
Independent Developer
San Antonio, Texas
E-mail address:
rebelrob1@yahoo.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform