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