#1062 - Duplicate entry '' for key 'unique_id' When Trying to add UNIQUE KEY (MySQL) -


i've got error on mysql while trying add unique key. here's i'm trying do. i've got column called 'unique_id' varchar(100). there no indexes defined on table. i'm getting error:

#1062 - duplicate entry '' key 'unique_id'  

when try add unique key. here screenshot of how i'm setting in phpmyadmin:

enter image description here

here mysql query that's generate phpmyadmin:

alter table  `wind_archive` add  `unique_id` varchar( 100 ) not null first , add unique ( `unique_id` ) 

i've had problem in past , never resolved rebuilt table scratch. unfortunately in case cannot there many entries in table already. help!

the error says all:

duplicate entry ''  

so run following query:

select unique_id,count(unique_id) yourtblname group unique_id having count(unique_id) >1 

this query show problem

select * yourtblname unique_id='' 

this show there values have duplicates. trying create unique index on field duplicates. need resolve duplicate data first add index.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -