I am currently running the following SQL statement on my MySQL database:
INSERT INTO `Table` (`Col1`, `Col2`, `Col3`) VALUES ('a','b','c')
ON DUPLICATE KEY UPDATE `Col1`=`Col1`, `Col2`=`Col2`, `Col3`=`Col3`
However, everytime I do run it, I get the following error: #1205 - Lock wait timeout exceeded; try restarting transaction
. It's pretty horrible, because I don't know what exactly went wrong. My intention is to update all the values of the existing row (with the exception of id
, which is the table's primary key).
If you do have any idea, please let me know!
EDIT: More info... the id
is an auto-incremented field. There is also another UNIQUE
column (let's call it IdentityNo
, and so what I'd like the statement to do is to: 1. insert if there is no conflict in IdentityNo
, and 2. update that existing row if there is a conflict (without changing the id
).