I have got a table that got a column with duplicate values. I would like to update one of a 2 duplicate values so for example row1 = tom and row2 = tom
I have found this solution:
My table devices already have data and the "serial" column should be unique. The "id" is a primary key. A random 6 digits value is concatenated after the original value.
UPDATE devices
SET serial=CONCAT(serial,'_',LPAD(FLOOR(RAND() * 999999.99), 6, '0'))
where id in
(select * FROM(
SELECT d1.id as id
FROM devices as d1, devices as d2
WHERE d1.id <> d2.id and d1.serial=d2.serial) as subdevices
)