> user drop primary key;". Work fine. But "alter table user add primary key
> (userName)" didn't work. It print "ERROR 1062: Duplicate entry 'a' for key
> 1". What's wrong? Help me.

This means that you have more than one record with the same value under the
userName column...

try this

SELECT userName, count(userName) FROM user GROUP BY userName HAVING cnt > 1;

This will display all the 'userName's that are in more than one record.
Simply remove the duplicates and then you should have no problem adding the
primary key

Sincerely,

Craig Vincent


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to