Re: [GENERAL] Using subquery or creating temp table

2008-10-10 Thread Grzegorz Jaƛkiewicz
temporary tables make sens, if you want to operate on multiple queries in the same connection.Also, temporary tables are visible only to the connection, if multiple connections will create temp table by the same name - they all will see their own content, ie - it is not shared between connections.

[GENERAL] Using subquery or creating temp table

2008-10-10 Thread Andrus
Test table: CREATE TABLE t1 ( col1 int, col2 int, ... ); Subquery SELECT * FROM t1 WHERE col1=2 Is it OK to use this subquery two times in same statement or should temp table created to prevent subquery executing twice? Which is better SELECT * ( SELECT * FROM (SELECT * FROM t1 WHERE col1=2)