General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
>lsqlstring = " SELECT Purchase.*, Accmst.accname, Depts.deptname;
> FROM purchase LEFT OUTER JOIN accmst;
> LEFT OUTER JOIN depts ;
> ON Purchase.department = Depts.deptno ;
> ON Purchase.partycode = Accmst.acccd"
The problem is that ONs are matched to JOINs from the inside out. So your query says to join accmst to depts based on the condition purchase.department = depts.deptno. Then, it should join that result to purchase based on Purchase.partycode=Accmst.acccd.
To solve this, you have some alternatives, but the simplest is to make Purchase the innermost table in the query. Rewrite the joins as:
FROM accmst LEFT OUTER JOIN depts
LEFT OUTER JOIN Purchase
ON Purchase.Department=Depts.Deptno
ON Purchase.Partycode=Accmst.acccd
Tamar
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only