I need to build a utility that will copy one table to another and reorder it to go into the correct columns on the second table:
ex: table1.column1 ->goes to table2.column13
table1.column2 -> table2.column9
table1.column3 -> table2.column1
and so on......
Is there a function or a tutorial on a way to do this? I have done a copy table to tablenew but this is not the same. Thanks.
mark
Copy from table to table
Moderator: General Moderators
Code: Select all
mysql> select * from tst1;
+------+------+
| id | bid |
+------+------+
| 1 | as |
| 3 | qa |
| 6 | lu |
| 7 | hu |
| 34 | bra |
+------+------+
5 rows in set (0.01 sec)
mysql> select * from tst2;
Empty set (0.00 sec)
mysql> insert into tst2 select bid as qud, id as lid from tst1;
Query OK, 5 rows affected (0.03 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> select * from tst2;
+------+------+
| qud | lid |
+------+------+
| as | 1 |
| qa | 3 |
| lu | 6 |
| hu | 7 |
| bra | 34 |
+------+------+
5 rows in set (0.00 sec)
mysql>-
mccommunity
- Forum Commoner
- Posts: 62
- Joined: Mon Oct 07, 2002 8:55 am
Yes... thank you
Yes this is it, thanks.