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.
1.4m articles
1.4m replys
5 comments
57.0k users