0
votes

I'm having difficulty understanding the correct syntax for an insert with an on duplicate key update check.

I currently get an error with the query:

INSERT INTO users_items (q,id,uid)
ON DUPLICATE KEY UPDATE
q = q + ?, id = ?, uid = ?  

The unique key is uid + id together.

My error is:

 Syntax error or access violation: 1064 You have an error in your SQL syntax;
1
There should be more in the error message. It points to the actual issuezerkms
Where are the actual VALUES that you want to insert?DevlshOne

1 Answers

1
votes

VALUES is the required part (or SET or SELECT)

INSERT INTO users_items (q,id,uid)
VALUES (v1, v2, v3) -- <<< this is what you missed
ON DUPLICATE KEY UPDATE
q = q + ?, id = ?, uid = ?

Referene: