MySQL ldquo; Insertintoxxxonduplicatekeyupdaterdquo; problem. I encountered this usage when I was reading the code. I don't quite understand it. I Googled it.
Ldquo in MySQL; Insert into xxx on duplicate key updaterdquo; problem. I encountered this usage when I was reading the code. I don't quite understand it. I Googled it.
I encountered this usage while reading the code, but I don't quite understand it. I Googled it. It actually means that if the "on duplicate key update" statement is formulated at the end of the insert statement, when the insert row causes duplicate values in a unique index or primary key ,, execute the statement in update. Otherwise, a new row is inserted.
For example, if column a is defined as unique and the value is 1, the following statements have the same effect, that is, once the entry and exit records contain a = 1, directly update c = c + 1 without executing c = 3.
Insert into table (a, B, c) values (1, 2, 3) on duplicate key update c = c + 1;
Update table set c = c + 1 where a = 1;
It is also worth mentioning that this statement is in mysql, but not in standard SQL statements.