Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is wrong in my sql statement
Message
From
15/11/2000 13:50:40
 
 
To
15/11/2000 13:20:28
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00442223
Message ID:
00442240
Views:
13
>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
Map
View

Click here to load this message in the networking platform