Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with a View
Message
From
20/10/1998 14:19:17
Steve Ramsower
Alliant Insurance Sevices, Inc.
California, United States
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00148071
Message ID:
00148588
Views:
16
Hi Ken,
What seems to be happening is caused by an odd behavior that multiple joins have. I don't know if this is entirely correct, but it is as though the joins are nested, that is, the join on Customer is not joining with the Payment table but the result of the join with Instructor, and so on.

You might try this:
CREATE VIEW v_payments as ;
SELECT Payment.*, Instructor.*, Customer.*, Student.*;
FROM ls!payment ;
LEFT OUTER JOIN ls!instructor;
ON Payment.pay_inst = Instructor.ins_inst ;
LEFT OUTER JOIN ls!customer;
ON Payment.pay_acct = Customer.cus_acct ;
LEFT OUTER JOIN ls!student;
ON Payment.pay_acct = Student.stu_acct and ;
Payment.pay_sub = Student.stu_sub

I have seen this technique work well but there is a problem.
The FoxPro View Designer cannot seem to deal with non-nested joins.
So you will not be able to use the GUI for adding Updating or other re-entrant features to the view.

Good Luck!
Steve



>>I have 4 tables that I am trying to work with in creating a view. I have a payment file that has and instructor # as a field that relates to the instructor table. The payment file also has an Account# field that relates to a Customer table. And finally since one customer can have multiple students there is a subacct field in the payment file.
>>I need both the account# and subacct values to find a match in the student file.
>>
>>Anyway here is the code I am trying to use to create a view:
>>
>>
>>CREATE VIEW v_payments as ;
>>SELECT Payment.*, Instructor.*, Customer.*, Student.*;
>> FROM  ls!payment LEFT OUTER JOIN ls!instructor;
>>    LEFT OUTER JOIN ls!customer;
>>    LEFT OUTER JOIN ls!student;
>>   ON  Payment.pay_acct = Student.stu_acct and ;
>>       Payment.pay_sub = Student.stu_sub ;
>>   ON  Payment.pay_acct = Customer.cus_acct ;
>>   ON  Payment.pay_inst = Instructor.ins_inst
>>
>>
>>The join seems to be working for the instructor, but I get the same customer and student record for every payment record. Its not getting the correct Customer or Student record.
>>
>>I am really struggling with how to create this view.
>>
>>TIA
>>
>>Paul
>
>You need to add a WHERE clause to finish this up.
Previous
Reply
Map
View

Click here to load this message in the networking platform