Inserting with a Unique Index

suggest change
UPDATE Customers SET Email = 'richard0123@example.com' WHERE id = 1;

This fails if a unique index is set on the Email column of Customers and another row already has that address. ON DUPLICATE KEY is not valid on UPDATE. In MySQL it is an INSERT clause, and it requires an update assignment:

INSERT INTO Customers (id, Email)
VALUES (1, 'richard0123@example.com')
ON DUPLICATE KEY UPDATE Email = VALUES(Email);

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents