doc - How to change duplicate rows to unique values in mysql databse -
i have database table 1m records. need find duplicate names in table , make them unique.
id name
1 2 3 b 4 c 5 c should changed to...
id name
1 2 a-1 3 b 4 c 5 c-1 there effective way of doing mysql query or procedure?
thanks in advance!
i needed similar table working on. needed unique url field previous keepers of data did not keep these constraints. key create temp table.
i used response here help: mysql error 1093 - can't specify target table update in clause
take note doesn't perform well, again if need run once on database clean table shouldn't bad.
update `new_article` `upd` set `upd`.`url` = concat(`upd`.`url`, '-', `upd`.`id`) `upd`.`url` in( select `url` ( select `sel`.`url` `new_article` `sel` group `sel`.`url` having count(`sel`.`id`) > 1 ) `temp_table` );
Comments
Post a Comment