create trigger m_trigger after update on table1
for each row
begin
if( old.status!= new.status)
then
select count(id) from table1 where stats='y' into @ycount;
select max(num) from table2 into @maxycount;
if( @ycount> @maxycount)
then
insert into table2 (num) select count(1) from table1 b where b.statu='y';
end if;
end if;
end
注:mysql中变量不用事先声明,用时直接‘@变量名’使用。
1、set @num=1; set @num:=1;
2、select count(id) from table1 where stats='y' into @ycount;
如对本文有疑问, 点击进行留言回复!!
项目实战: CMDB自动化资产扫描(搞懂这个项目 算你没白学运维)
MySQL中建表时可空(NULL)和非空(NOT NULL)的用法详解
SSD原理及Pytorch代码解读——网络架构(二):特征提取网络及总体计算过程
网友评论