in SQL

Cloning rows in a mysql table

If you have a lot of data in a mysql table and you’d like to duplicate some of the rows – maybe with a change or two as well – then here is the sql you’ll need…

INSERT INTO table (column1, column2,column3, column4)
SELECT column1, 234, column4, NOW()
FROM table
WHERE id IN (6,7)

You have some choices…
You can copy or clone from one table to another by changing the table names above.
You can define your own values. Examples of 234 and NOW() are above.
You can include or drop the WHERE clause to choose which (if not all) rows to clone