On your table cl56-goldeng.users
, the field email
was specified on creation to not allow more than 1 of the same value to be allowed into it. This is done using the UNIQUE
identifier on table creation in MySQL. You can see more on the UNIQUE identifier at this link.
You have 2 options that you could go about doing.
- First would be to remove the unique constraint on the
email
field. This entirely depends on your logic in your code, but seeing as emails should almost always be unique, this is not suggested.
You can drop a unique key by running the command:
alter table [table-name] drop index [unique-key-index-name];
- Second, would be to use
NULL
instead of an empty string. My assumption is that you are setting an empty string when the users email does not exist. In this scenario, it would be better to use NULL
, and then check for that when retrieving data from the database.
You can insert a NULL
value by using the NULL
identifier in your MySQL
statement, like such:
INSERT INTO users (firstName,lastName,email)
VALUES ('Bob','Ross',NULL);
And then check for a NULL
value in whatever language you are accessing this data from.