I am inserting some data into a table, but it occasionally clashes with other data in the table (ie. it has the same primary key).
I would like to be able to just overwrite this data if it is there, instead of having mysql send me an error message saying that there is a duplicate primary key. I know that I can just delete these values beforehand, but it would take a somewhat large query.
Is it possible to overwrite these values and suppress any warnings, or am I forced to remove these values?
Just a little cheatsheet.
Mysql has 3 different scenarios for handling unique key duplicates:
If you want to...
INSERT IGNORE
REPLACE INTO
ON DUPLICATE UPDATE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With