Reputation: 4008
I'd like to copy data from one table to another.
I'd like to copy some data, let's say: "Andy". His number is "5" and his data is "cool".
This is stored in table 1.
Now i'd like to insert the data "cool" into table 2 WHERE number is "5".
SQL
INSERT TO table2 SET data = (SELECT data FROM table1 WHERE number = table2.number)
So, this should copy data from multiply users, like a loop.
How should i do this?
Upvotes: 0
Views: 212
Reputation:
If you need to update the values of Table2 from values of Table1, you can use update statement with joins.
UPDATE Table2
JOIN Table1 ON Table1.number = Table2.number
SET Table2.data = Table1.data;
Upvotes: 2