To duplicate the contents of a table full of itself, just use:
1 | * FROM MYTABLE INSERT INTO SELECT * FROM MyTable MYTABLE |
You can also use the Claus WHERE if necessary:
1 | * FROM MYTABLE WHERE a = b INSERT INTO SELECT * FROM MyTable WHERE MYTABLE a = b |
If the table has any index or unique key, which would cause an error, you can filter the fields to be duplicated:
1 | field1 , field2 , ... ) SELECT field1 , field2 , ... FROM MYTABLE INSERT INTO MYTABLE (field1, field2, ...) SELECT field1, field2, ... FROM MyTable |
Even you can duplicate a record and change a value, such as dual field and add 1:
1 | field1 , field2 , ... ) SELECT ( field1 + 1 ) , field2 , ... FROM MYTABLE INSERT INTO MYTABLE (field1, field2, ...) SELECT (field1 + 1), field2, ... FROM MyTable |










There are no comments for this post
Leave a comment