If a record is required to be implemented in MySQL, insert is not present, and the update operation does not exist. You can use the following statement:
To update a field:
INSERT into TBL (COLUMNA,COLUMNB,COLUMNC) VALUES (1,2,3) on DUPLICATE KEY UPDATE columna=if (Columnb>0,1,columna)
To update multiple fields:
INSERT into TBL (COLUMNA,COLUMNB,COLUMNC) VALUES (1,2,3) on DUPLICATE KEY UPDATE columna=if (Columnb>0,1,columna), Columnb=if (COLUMNC>0,1,COLUMNB), columnc=if (COLUMNA>0,1,COLUMNC);
Because MySQL is optimized for the same value as the original, updating to the same value does not actually update the field, and there is no performance problem.
The above is a small set to introduce in MySQL to implement INSERT or update operations (similar to Oracle's merge statement), I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!