I have to use INSERT
and UPDATE
in single query. For that SQL having MERGE
statement.
Is MERGE
statement supported in MySQL. If supported, please provide sample.
I have to use INSERT
and UPDATE
in single query. For that SQL having MERGE
statement.
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.