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?

阅读 2.1k
1 个回答

?,为什么总有人把这种update/set语法都搞错,update table set A=X,B=X where ..; 不是什么set A=X and B=X .. 这里的on duplicate key update后面也是一样。。。 不能用and。。。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题