Jason
Jason

Reputation: 821

MySQL ON DUPLICATE KEY UPDATE does not update but inserts

INSERT INTO TABLE(APIKEY, CLIENTID, rID) VALUES('33333meow', '2', '3')
ON DUPLICATE KEY UPDATE APIKEY='meo11111111w';

The above code will insert but if run a second time, the APIKEY field does not update it just inserts another row.

I've looked at documentation and it looks correct. What else am I doing wrong?

Upvotes: 1

Views: 335

Answers (1)

Poul Kruijt
Poul Kruijt

Reputation: 71901

Create a unique key on your table. Probably the columns clientid and rid. That will trigger the duplicate key trigger

Upvotes: 2

Related Questions