Is a merge expression available in MySQL

I have to use INSERTand UPDATEin one request. For this, SQL with a statement MERGE.

Whether the statement is supported MERGEin MySQL. If supported, please provide a sample.

+12
source share
1 answer

MERGE MySQL is not supported, but there is another way to do the same:

INSERT ... ON DUPLICATE KEY UPDATE

If you specify the ON DUPLICATE KEY UPDATE option in INSERT and the new row causes a duplicate value in the UNIQUE or PRIMARY KEY index, MySQL updates the old row based on the new values.

+20
source

Source: https://habr.com/ru/post/1671768/


All Articles