I have a query which updates the table or inserts if the row does not already exist, but for some reason it just inserts all the time.
This is my table structure:
Id (primary) | uid | product_id | quantity
This is my query:
INSERT INTO my_table (uid,product_id,quantity)
SELECT t1.uid,?,?
FROM checker t1
WHERE t1.id = ?
ON DUPLICATE KEY UPDATE
product_id = ?, quantity = quantity+?
What i want to do though is use on duplicate key if uid + product_id combination exist in the table already.
So is there a way to designate what kind of duplication to look for to update instead of insert?