Mysql 触发器 同时更新多张表
CREATETRIGGERt_AfterUpdate_on_mst_officecurrency2AFTERUPDATEON`mst_officecurrency`FOR...
CREATE TRIGGER t_AfterUpdate_on_mst_officecurrency2
AFTER UPDATE ON `mst_officecurrency`
FOR EACH ROW
update `mst_generalsetup` set `CurrencyName`=NEW.OfficeCurrencyName where `CurrencyName`=OLD.OfficeCurrencyName
and
update `mst_office` set `Currency`=NEW.OfficeCurrencyName where `Currency`=OLD.OfficeCurrencyName; 展开
AFTER UPDATE ON `mst_officecurrency`
FOR EACH ROW
update `mst_generalsetup` set `CurrencyName`=NEW.OfficeCurrencyName where `CurrencyName`=OLD.OfficeCurrencyName
and
update `mst_office` set `Currency`=NEW.OfficeCurrencyName where `Currency`=OLD.OfficeCurrencyName; 展开
2个回答
展开全部
虽然不明白你的问些什么,但里面有几个语法错误我帮你改一下
CREATE TRIGGER t_AfterUpdate_on_mst_officecurrency2
AFTER UPDATE ON `mst_officecurrency`
FOR EACH ROW
begin
update `mst_generalsetup` set `CurrencyName`=NEW.OfficeCurrencyName where `CurrencyName`=OLD.OfficeCurrencyName;
update `mst_office` set `Currency`=NEW.OfficeCurrencyName where `Currency`=OLD.OfficeCurrencyName;
end;
CREATE TRIGGER t_AfterUpdate_on_mst_officecurrency2
AFTER UPDATE ON `mst_officecurrency`
FOR EACH ROW
begin
update `mst_generalsetup` set `CurrencyName`=NEW.OfficeCurrencyName where `CurrencyName`=OLD.OfficeCurrencyName;
update `mst_office` set `Currency`=NEW.OfficeCurrencyName where `Currency`=OLD.OfficeCurrencyName;
end;
追问
我有一个问题就是,我用的是Mysql5.1 ,然后用的是Mysql Query Browser,是不支持begin end的。所以我也不知道为什么不行
追答
Mysql5.1 是支持begin end块的,至于Mysql Query Browser我就没用过了,你或都可以直接使用mysql -h xx.xx.xx.xx -u xxx -p登陆到服务器执行
展开全部
CREATE TRIGGER t_AfterUpdate_on_mst_officecurrency2
AFTER UPDATE ON `mst_officecurrency`
FOR EACH ROW
bengin
update `mst_generalsetup` set `CurrencyName`=NEW.OfficeCurrencyName where `CurrencyName`=OLD.OfficeCurrencyName
and
update `mst_office` set `Currency`=NEW.OfficeCurrencyName where `Currency`=OLD.OfficeCurrencyName;
end
AFTER UPDATE ON `mst_officecurrency`
FOR EACH ROW
bengin
update `mst_generalsetup` set `CurrencyName`=NEW.OfficeCurrencyName where `CurrencyName`=OLD.OfficeCurrencyName
and
update `mst_office` set `Currency`=NEW.OfficeCurrencyName where `Currency`=OLD.OfficeCurrencyName;
end
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询