I found this script and tried it. It worked. I thought it was useful for a variety of situations and is easy to follow.
Often times I need nearly duplicated data and don't want to manually cut and paste.
- CREATE TABLE temporary_table AS SELECT * FROM sometable WHERE website_id=4;
- UPDATE temporary_table SET website_id=5;
- UPDATE temporary_table SET sometable_primary_key_id=NULL;
- INSERT INTO sometable
- SELECT * FROM temporary_table;
- DROP TABLE temporary_table;
You need to login to post a comment.