鍍金池/ 問答/數(shù)據(jù)庫/ on duplicate key update

on duplicate key update

create table test(
id int not null primary key,
num int not null UNIQUE key,
tid int not null
)
id num tid
1 2 3
2 3 3
insert into test(`id`, `num`, `tid`) values(1,2,3),(2,3,3) on duplicate key update `id`= VALUES(id) AND `num`= VALUES(num) AND `tid` = VALUES(tid) + 1;
1062 - Duplicate entry '0' for key 'PRIMARY'
時間: 0.001s

How to fix it?

回答
編輯回答
擱淺

?,為什么總有人把這種update/set語法都搞錯,update table set A=X,B=X where ..; 不是什么set A=X and B=X .. 這里的on duplicate key update后面也是一樣。。。 不能用and。。。

2017年12月24日 09:37