6 messages in com.mysql.lists.mysqlRe: Troubles with joining tables (cont)
FromSent OnAttachments
Seth Price02 Mar 2003 13:41 
Seth Price02 Mar 2003 14:32 
Bruce Feist02 Mar 2003 16:31 
Bruce Feist02 Mar 2003 16:31 
Seth Price02 Mar 2003 18:27 
Bruce Feist02 Mar 2003 20:26 
Subject:Re: Troubles with joining tables (cont)
From:Bruce Feist (bfe@flock.org)
Date:03/02/2003 04:31:59 PM
List:com.mysql.lists.mysql

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?