Update: Here is a more advanced use of INSERT INTO … SELECT … to combine multiple tables into one.
While CREATE TABLE … SELECT … mix and mingle records by column from other tables into a table that’s created on the fly, INSERT INTO … SELECT … insert those generated or combined records into an existing table.
Both approaches bear the same grammatical form and you need only change CREATE TABLE to INSERT INTO if what you are dealing is an existent table.
INSERT INTO mingle1 SELECT table1.col1, table1.col3, table2.col2, table2.col6 FROM table1, table2
Therefore you can update the table created with the previous approach and insert newly generated records simply by using the slightly modified query version above.
You should also read:
- SQL: CREATE TABLE … SELECT … to generate new table from existing tables
- Using SQL to Find records existing in one table but not in another
- MySQL: INSERT INTO … SELECT … FROM … Selectively on Table Columns / Fields to Combine Multiple Tables into One
- SQL: Randomly Shuffle Rows or Records – Reorder them in a random order
- MySQL: Update Multiple Rows or Records with One Single Query


Facebook
Twitter
Google Plus
{ 2 comments… read them below or add one }
i can update the table created with the previous approach and insert newly generated records simply by using the slightly modified query version above.
good job
{ 1 trackback }