If you want ON DUPLICATE KEY UPDATE actually do nothing, just set the column value to the existing value. Other conflicts, such as foreign key constraints, will bubble, unlike using the IGNORE keyword, but no values โโwill change in the conflict.
INSERT INTO table (value1, value2) VALUES ('1', '2') ON DUPLICATE KEY UPDATE value1 = value1;
If you want to avoid reliable data in the event of a conflict, you can add a column with arbitrary data to the table in the table and use this for the UPDATE .
The third option, if you want to save all the logic in your application, and not in the database, first run the SELECT to check for potential conflicts before running your INSERT/UDPATE .
Although there is an exception for your scenario, the stored procedure will also be able to provide this logic in a single database call.
doublesharp
source share