我试图设置一个触发器,它会通过从另一个表中插入一些额外的数据来更新同一行。字段receive.iccid是空白的,我希望每次插入都更新它。但是这个触发器不起作用
delimiter //
CREATE TRIGGER ins_iccid
AFTER INSERT ON receive
FOR EACH ROW
BEGIN
UPDATE receive SET NEW.iccid = (SELECT goip.iccid FROM goip WHERE NEW.goipname=goip.name);
END//
delimiter ;
答案 0 :(得分:0)
原来我需要使用'BEFORE INSERT'来实现我想要的东西
CREATE TRIGGER `ins_iccid` BEFORE INSERT ON `receive`
FOR EACH ROW
BEGIN
SET NEW.iccid = (SELECT goip.iccid FROM goip WHERE NEW.goipname=goip.name);
END