Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What is wrong in my sql statement
Message
De
15/11/2000 13:50:40
 
 
À
15/11/2000 13:20:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00442223
Message ID:
00442240
Vues:
8
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform