DELIMITER $$
DROP TRIGGER IF EXISTS `UPDATEtrigger_tbl_enterprice_user` $$
CREATE
TRIGGER `UPDATEtrigger_tbl_enterprice_user` AFTER UPDATE
ON `tbl_enterprise_user`
FOR EACH ROW BEGIN
declare log_id int(10);
declare username_tr varchar(100);
declare user_id int(10);
set log_id=(select max(log_id) FROM tbl_public_log);
set user_id=(select id from tbl_enterprise_user where login_time=(select max(login_time) from tbl_enterprise_user));
set username_tr=(select username from tbl_enterprise_user where login_time=(select max(login_time) from tbl_enterprise_user));
IF NEW.login_time<>OLD.login_time
THEN
insert into tbl_public_log values(log_id+1,'1','登录',NEW.ID,SYSDATE(),'1',NEW.username);
ELSEIF NEW.password<>OLD.password
THEN
insert into tbl_public_log values(log_id+1,'1','修改密码',user_id,SYSDATE(),'1',username_tr);
ELSE
insert into tbl_pu
Mysql触发器-保留 日后参考
最新推荐文章于 2022-07-27 21:34:47 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)