按道理来说我输入
insert into shangban (y_id,time1) value('03','07:06:00');
这个代码之后,在表里会自动输入status1了吧
delimiter ??
create trigger kaoqin before insert on shangban
for each row
begin
declare a time;
declare b time;
declare c time;
set a =New.time1;
set b =(select sbtime from shijian where shijianduan='下午');
set c =(select sbtime from shijian where shijianduan='上午');
case
when TIMESTAMPDIFF(minute,c,a)<=0 and TIMESTAMPDIFF(minute,b,a)<=0 then set@new.status1 ='正班';
when TIMESTAMPDIFF(minute,c,a)>0 and TIMESTAMPDIFF(minute,c,a)<=5 and TIMESTAMPDIFF(minute,b,a)<=0 then set @new.status1='迟到';
when TIMESTAMPDIFF(minute,c,a)>5 and TIMESTAMPDIFF(minute,c,a)<=300 and TIMESTAMPDIFF(minute,b,a)<=0 then set @new.status1 ='旷工';
when TIMESTAMPDIFF(minute,c,a)>300 and TIMESTAMPDIFF(minute,b,a)<=0 then set @new.status1 ='正班';
when TIMESTAMPDIFF(minute,b,a)>0 and TIMESTAMPDIFF(minute,b,a)<=5 then set @new.status1 ='迟到';
when TIMESTAMPDIFF(minute,b,a)>5 and TIMESTAMPDIFF(minute,b,a)<=180 then set @new.status1 ='旷工';
else set @status1 ='数据错误';
end case;
end ??