How can I allow duplicate entries in MYSQL?

989 views mysqli

I'm using phpmyadmin and want to be able to import an .sql file that contains duplicate entries in the 'code' field. I haven't been able to figure out how to get MySQL to allow it. Attached are an images that show the error when I try to import and another image showing the structure of the table in the database involved.

Any help is appreciated!

Displayed error table structure as shown in phpmyadmin

Here's the error

Blockquote Error

SQL query:

ALTER TABLE commands


ADD UNIQUE KEY code (code)

ADD KEY code_2 (code)

ADD KEY code_3


MySQL said: Documentation

1062 - Duplicate entry '280' for key 'code'

answered question

No errors viewable in what you attached. Try just pasting in the text of the error.

1 Answer


No error in the screenshot you pasted.As per the screenshot id is your primary key not code. So, it must allow duplicate values. could you please recheck or elaborate a bit. Instead of duplicate,code column will not allow null values as you have chosen.


posted this

Have an answer?


Please login first before posting an answer.