Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select misses records
Message
 
 
À
09/01/2008 18:04:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01280720
Message ID:
01280726
Vues:
22
The OUTER JOIN does include all records from the sites table but some of them are filtered out by WHERE conditions on the table on the right of LEFT JOIN. You should move such conditions FROM WHERE into JOIN so they are applied before JOIN.

>This select statment
>
>select sites.permid as permid, sites.site_name, sites.startdate, sites.enddate, ;
>	pei.*, GetERInitials(sites.er) as ER,  ;
>	h.surveys_distributed ;
>	from newbluebook!sites ;
>	left outer join new_pe_pei_database!PEI ;
>		on sites.permid=pei.permid ;
>	left outer join newsurveys!history h;
>		on sites.permid=h.permid ;
>	where ! isblank(startdate) and isblank(enddate) and ;
>	pei._year = lnYear and ;
>	h._year = lnYear-1 ;
>	order by sites.er, site_name ;
>	into cursor crsReport	
>
>misses records where there is no matching history record. I thought the outer join would include ALL of the qualified sites records but this is apparently not the case. What do I have wrong?
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform