【发布时间】:2019-12-27 16:03:49
【问题描述】:
这是我的 SQL 查询, 下面插入或更新返回 0 行受影响.. 我哪里出错了?
insert into biometric_data.daily_attendance (emp_id, in_punch, out_punch, processeddate_d, worktime)
values ('A744', '27/12/2019 09:08:31', '27/12/2019 18:56:49', '2019-12-27', '8:48')
on duplicate key update emp_id = 'A744', processeddate_d = '2019-12-27';
当我说,
select *
from attendance
where emp_id = 'A744' and processeddate_d = '2019-12-27';
返回 1 行。
A744 11:30 null 2019-12-27 8:48
但更新不起作用。
注意:浏览了许多帖子并尝试了所有方法,但我仍然找不到错误的地方。
我的 PK 是 id 一个自动字段和 index-> emp_id, processeddate_d unique-> emp_id, processeddate_d
【问题讨论】:
标签: mysql insert sql-update on-duplicate-key