SQL: INSERT INTO … SELECT … to generate or combine records from existing ones and insert into an existing table

by Yang Yang on January 4, 2009

Share This Article:
Subscribe to Kavoir: blog feed

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.

Share This Article:
Subscribe to Kavoir: blog feed

You should also read:

{ 2 comments… read them below or add one }

leather living room furniture March 1, 2010 at 7:13 pm

i can update the table created with the previous approach and insert newly generated records simply by using the slightly modified query version above.

Reply

vinamra khamkar September 20, 2010 at 11:41 pm

good job

Reply

Leave a Comment

{ 1 trackback }

Previous post:

Next post: