duplicate entry
# The main Reason you are grtting this error is because
#there is a unque flag on the field. lets see an example
# CREATE A NEW TABLE CALLED User;
CREATE TABLE User(
# this will not trigger duplicates because of the auto_increment option
id int unsigned primary key auto_increment
name VARCHAR(255) not null,
# this field will always trigger the error if you leave it empty or if you
# insert a user with same email as the one in the table already.
email VARCHRA(255) unique
)
# INSERT DAta INTO THE TABLE.
INSERT INTO User(name, email) VALUES('Sample Name','[email protected]') # This will pass
INSERT INTO User(name, email) VALUES('Sample2 Name','[email protected]') # This will not pass
# the second insert query will yield an error because the email already exists in the database.
# to avoid this error make sure that the unique field is always checked before insert into the table.