I have a mysql table users.
A column named Email contains NULL value.
I’m not able to create a unique key on email. It is showing an error saying duplicate value ''.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s because you have multiple records on the email column with the value empty:
''If you use InnoDB you can have multiple
NULLvalues, but you can not have multiple empty values''.Try to clean the empty values with
UPDATE users SET email = NULL WHERE email = ''and then create the unique key.