Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
JOIN vs WHERE
Message
 
À
09/05/2003 14:28:46
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00786891
Message ID:
00786912
Vues:
23
Just want to add to Sergey' replay. Compare
SELECT ;
crsPMPlan.IDNum, ;
crsPMPlan.PlanID, ;
crsPMPlan.ContID, ;
crsPMPlan.UserID, ;
crsPMPlan.Pin ;
FROM crspmplan ;
WHERE ....
with

SELECT ;
crsPMPlan.IDNum, ;
crsPMPlan.PlanID, ;
crsPMPlan.ContID, ;
crsPMPlan.UserID, ;
crsPMPlan.Pin ;
FROM crspmplan, crsPMPlanH ;
WHERE ....

to see the difference even without JOIN.

>The 1st SQL returns 1 record like I expected, but why does the 2nd SQL return all the records in the crsPMPlan table? I would have expected the results to be the same.
>
>
>SELECT ;
>	crsPMPlan.IDNum, ;
>	crsPMPlan.PlanID, ;
>	crsPMPlan.ContID, ;
>	crsPMPlan.UserID, ;
>	crsPMPlan.Pin ;
>	FROM crspmplan ;
>	WHERE ;
>		(crspmplan.IDNum == crspmplanh.IDNum) AND ;
>		(ALLTRIM(crspmplan.USERID) == ALLTRIM(crspmplanh.USERID)) AND ;
>		(ALLTRIM(crspmplan.Pin) == ALLTRIM(crspmplanh.Pin)) ;
>	GROUP BY ;
>		crsPMPlan.IDNum, ;
>		crsPMPlan.PlanID, ;
>		crsPMPlan.UserID, ;
>		crsPMPlan.Pin ;
>	INTO CURSOR tmpWork
>
>
>
>
>SELECT ;
>	crsPMPlan.IDNum, ;
>	crsPMPlan.PlanID, ;
>	crsPMPlan.ContID, ;
>	crsPMPlan.UserID, ;
>	crsPMPlan.Pin ;
>	FROM crspmplan ;
>	JOIN crsPMPlanH ON (crspmplan.IDNum == crspmplanh.IDNum) ;
>	WHERE ;
>		(ALLTRIM(crspmplan.USERID) == ALLTRIM(crspmplanh.USERID)) AND ;
>		(ALLTRIM(crspmplan.Pin) == ALLTRIM(crspmplanh.Pin)) ;
>	GROUP BY ;
>		crsPMPlan.IDNum, ;
>		crsPMPlan.PlanID, ;
>		crsPMPlan.UserID, ;
>		crsPMPlan.Pin ;
>	INTO CURSOR tmpWork
>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform