February 13, 2012
Posted by on
Temporary Tables, or temp tables for short, allow you to create a short-term storage place within the database for a set of data that you need to use several times in a single series of operations. Temp tables come into play when it isn’t possible to retrieve all the data that you require using one SELECT statement or when you want to work with subsets of the same, larger resultset over several successive operations. Temp tables are supported in MySQL 3.23 and later.
Quote from http://www.linuxplanet.com/linuxplanet/tutorials/6889/1
CREATE TEMPORARY TABLE new_tbl SELECT * FROM orig_tbl;
INSERT INTO newtable
SELECT title, hits, userid
FROM oldtable WHERE title <> ''
ORDER BY title;