I have a Mysql table with one primary key (called pkey) that grows automatically, and I would like to clone one row, keeping all the data the same, except for the primary key, which should become the next available value as determined by auto-increment.
My first question is: is the following query possible?
UPDATE `table` SET pkey='next_available_primary_key' WHERE pkey='old_primary_key'
if you tried
UPDATE `table` SET pkey=null WHERE pkey='old_primary_key'
But it only sets the primary key value to zero. Thank you in advance for any help / suggestions.
UPDATE:
I think I should add that I really don't need two copies of the data in the table. I just want to change the primary key. So if I used INSERT SELECT, I would have to compensate for using ON DUPLICATE KEY UPDATE pkey = 'next_available_primary_key', I'm just not sure how to do this ...
source share