我必须在单个查询中使用 INSERT
和 UPDATE
。对于具有 MERGE
语句的 SQL。
MySQL 是否支持MERGE
语句。如果支持,请提供示例。
最佳答案
MERGE
不受 MySQL 支持,但是,还有其他可能的方法:
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.
关于mysql - 合并语句在MySQL中可用吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42663074/