I’m trying to do this:
INSERT INTO table (id, hits) VALUES ('abc', 1), ('cde', 1), ('fgh', 1)
ON DUPLICATE KEY UPDATE hits = VALUES (2), (6), (10)
The code is wrong (probably would need to put the id in the key update) but is there anyway to do this?
You need to use
VALUESproperly, it’s really rather simple:EDIT: if you desperately need to assign hits different values in single query on duplicate key than in the insert query, try CASE operator.