MySQL: updating a row and deleting the original in case it becomes a duplicate
- by Silvio Donnini
I have a simple table made up of two columns: col_A and col_B.
The primary key is defined over both.
I need to update some rows and assign to col_A values that may generate duplicates, for example:
UPDATE `table` SET `col_A` = 66 WHERE `col_B` = 70
This statement sometimes yields a duplicate key error.
I don't want to simply ignore the error…