Copying records in MySQL
Copying records from one table to another can be a very basic requirement. But writing queries to perform this task can be bit of a work around. But there is a very simple query to get this done.
Its by using INSERT … SELECT
http://dev.mysql.com/doc/refman/5.0/en/insert-select.html
Copy one record from a table to another
1 | INSERT INTO `dest_table` SELECT * FROM source_table WHERE id = '10' |
It can be very simple as this. Even multiple records can be copied from a single table or several tables. If I'm not mistaken INSERT … SELECT works on MySQL versions 4.1 and above.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.









Insert selects work on MySQL 3.23 and over.
They also work in other databases (oracle and postgres for sure)
Thanks for the info.. Didn't know that it worked with other DBs as well