-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?

David Refoua
  • 3,476
  • 3
  • 31
  • 55
ZZZ
  • 27
  • 6

1 Answers1

2

just set the unique value with the original value, (Assuming ProductID is unique) eg,

INSERT INTO CART (ProductID, Quantity)
VALUES (1, 100)
ON DUPLICATE KEY UPDATE ProductID = ProductID;
John Woo
  • 258,903
  • 69
  • 498
  • 492