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.
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)