I have to use INSERT and UPDATE in single query. For that SQL having MERGE statement.
INSERT
UPDATE
MERGE
Is MERGE statement supported in MySQL. If supported, please provide sample.
MERGE is not supported by MySQL, However, there is other possible way of doing the same:
INSERT...ON DUPLICATE KEY UPDATE
If you specify the ON DUPLICATE KEY UPDATE option in the INSERT statement and the new row causes a duplicate value in the UNIQUE or PRIMARY KEY index, MySQL performs an update to the old row based on the new values.
2.1m questions
2.1m answers
60 comments
57.0k users