0
posted on December 13, 2010 10:41 AM by Jhoy Imperial
under MySQL, Tutorials
tagged mysql script
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
"Nice" -- Romeo John
"How can I make a tabswitch, within a tab switch. When I try adding and switching class names, the in" -- The
"Nice post ! Keep up good work. I have also created similar kind of work in my blog to populate gri" -- Hitesh Agja
"Thanks. It's awesome." -- Tony Nguyen
"Thanks ;)" -- Kakha Giorgashvili