0

Multiple Insert Into a Table From Another Table

posted on December 13, 2010 10:41 AM by Jhoy Imperial
under MySQL, Tutorials
tagged

A query for transferring data from one table to another.

INSERT INTO table2  (field1,field2,field3)
SELECT col1, col2, col3 FROM table1 WHERE table1_field2 = 10

In this query, we want to transfer the data from table1 whose col2 fields are equal to 10.

Origin Table table1

col1 col2 col3
1 10 Apple
2 10 Banana
3 6 Orange
4 10 Cherry

Destination Table table2

field1 field2 field3

After the query, table2 would look something like this:

field1 field2 field3
1 10 Apple
2 10 Banana
4 10 Cherry

HTH

Be Sociable, Share!

Recent Tweets

Sponsored Links

 

"Minimalist Cereal 2"
design and theme by Jhoy Imperial

Email us at support@codingcereal.com

Copyright 2010 - 2011 © www.codingcereal.com