Reputation: 17
Say I have this table:
ID | Name
1 | Daniel
2 | Michael
1 | Lawrence
How can I via query find all the duplicated IDs and replace the other one with a new unique number, so that there are no longer duplicates?
Upvotes: 0
Views: 578
Reputation: 41
The simplest way is to drop the id column and re add the column as primary key autoincrement:
ALTER TABLE tableName DROP idColumnName;
and than
ALTER TABLE tableName ADD idColumnNameint NOT NULL PRIMARY KEY AUTO_INCREMENT;
Upvotes: 1