zwwcn

Just another WordPress.com site

Temporary tables

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

e.g:

CREATE TEMPORARY TABLE new_tbl SELECT * FROM orig_tbl;

INSERT  INTO newtable 
SELECT title, hits, userid 
FROM oldtable WHERE title <>  '' 
ORDER  BY title;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: