Seth Price wrote:
Since writing this message, I have discovered another possible way for
doing this with two successive SQL statements. It would look something
like this:
1) CREATE TEMPORARY TABLE temp SELECT DISTINCT xy FROM table2 WHERE
<all of table2 conditions>; (going by data below, maximum of 20k rows
because it is DISTINCT)
So the bulk of the selection criteria are on table2, not table1?
2) SELECT AVG(column1),<all other group calculations> FROM table1 LEFT
JOIN temp ON temp.xy=table1.xy WHERE <all of table1 conditions> AND
temp.xy IS NOT NULL; (maximum of 20k rows, less after both WHERE
statements tho)
Wouldn't you get the same result from your query by using an INNER JOIN
and dropping the temp.xy IS NOT NULL clause?