Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
JOIN vs WHERE
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Divers
Thread ID:
01406428
Message ID:
01406475
Vues:
59
>Hi Rich,
>
>It's not clear what you want so I'll take a guess
>
>SELECT  cust.customer, COUNT(*) ;
>	FROM crsAllCust cust;
>		JOIN crsFillRate fr ON cust.customer = fr.custshipm ;
>	WHERE EXISTS ( SELECT 1 FROM crsFillRate fr WHERE cust.customer = custshipm AND EMPTY(PartOrders)) ;
>	GROUP BY cust.customer
>
>
Hi Sergey,

This query would not return customers that don't have corresponding records in the crsFillRate. You can modify it to be
SELECT  cust.customer, COUNT(*) ;
	FROM crsAllCust cust;
	LEFT	JOIN crsFillRate fr ON cust.customer = fr.custshipm ;
	WHERE fr.custshipm  IS NULL OR EXISTS ( SELECT 1 FROM crsFillRate fr WHERE cust.customer = custshipm AND EMPTY(PartOrders)) ;
	GROUP BY cust.customer
to match the original query. But when why do we need EXISTS ?
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform