Stella740pl
Programmer
Can someone please help me explain this phenomenon?
While it works, I don’t really understand why it works this way, and it bothers me.
We are using VFP6.
Here is the setup.
The Avg_tmp table holds calculated on-the-spot (from a master table) monthly statistics.
The Template table contains only the names (and more of them than in the Avg_tmp table),
including some placeholder entries, currently inactive entries, etc.,
to match a special format for one of my internal clients’ Excel report.
(The resulting cursor I would just copy into Excel and paste the columns into their places in
that Excel file that holds several years worth of statistics.)
The statements are like this:
SELECT aa.name, ;
bb.avg_sch, ;
bb.avg_sat, ;
bb.avg_sun, ;
bb.avg_wkd ;
FROM template aa ;
LEFT JOIN avg_tmp bb ;
[red] ON aa.name==bb.name AND bb.ccyy=2008 AND bb.mth=7 ;[/red]
INTO CURSOR gl0708_1
SELECT aa.name, ;
bb.avg_sch, ;
bb.avg_sat, ;
bb.avg_sun, ;
bb.avg_wkd ;
FROM template aa ;
LEFT JOIN avg_tmp bb ;
[red] ON aa.name==bb.name ;
WHERE bb.ccyy=2008 AND bb.mth=7 ; [/red]
INTO CURSOR gl0708_2
The first statement works as I would expect it to work, selects all of the records from the Template table,
including all of the placeholders that I need there and whatever matches it from the Avg_tmp table.
The second one, while looks more correct to me than the first one (after all, bb.ccyy=2008 AND bb.mth=7
are filter conditions, not join conditions), don’t do what I expect it to do,
and, in fact, creates an inner join, selecting only those records that are found in both tables
(which would be only the records from the Avg_tmp table).
Am I missing something here?
Thanks,
Stella