Reputation:
I read about the MySQL command ON DUPLICATE KEY UPDATE
. I have a column Surnames
in a Users
table. Since there must be no identical surnames
, I want to INSERT a new surname
when the surname
isn't in the database, and leave the row as it was recorded if the surname
was previously saved in the database, without updating it. How can I achieve this?
Upvotes: 1
Views: 159
Reputation: 63797
INSERT IGNORE ...
will try to insert a new row, if a duplicate key is found the new data will be discarded.
Upvotes: 2