Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select misses records
Message
 
 
To
09/01/2008 18:04:43
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01280720
Message ID:
01280722
Views:
16
>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?

You can not add a condition in the where clause on the tables listed from the left, because doing so you're making the LEFT JOIN to be an INNER JOIN. You need to move these conditions into JOIN ON clause instead.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform