update触发器使用(1442错误)
使用Navicat Premium工具新建update触发器时,开始使用的是
BEGIN
update tableName
set new.col1 = col1 / 100
where new.state = 2;
end
测试时候使用update更新某一条state = 2,报错代码为1442,后查相关信息后改为如下代码后可用
BEGIN
if new.state = 2 then
set new.col1 = col1 / 100 ;
end if;
if new.state != 2 then
set new.col1 = null;
end if;
end
先在此记录问题的解决方案,原理待本人研究后,在回来此处更新