-4

I'm using the query INSERT INTO ... ON DUPLICATE KEY UPDATE ... in order to insert a record into the table, and if a row with duplicate keys already exists, this results in triggering an update.

I don't want any updates being performed on an existing row, if exist.

What should I do to update nothing when a row with duplicate keys exist?

4

1 回答 1

2

只需使用原始值设置唯一值,(假设ProductID是唯一的)例如,

INSERT INTO CART (ProductID, Quantity)
VALUES (1, 100)
ON DUPLICATE KEY UPDATE ProductID = ProductID;
于 2012-12-16T13:57:31.340 回答