DELIMITER $$
CREATE TRIGGER arrange_serial
AFTER DELETE ON db.table
FOR EACH ROW
BEGIN
UPDATE db.table set serial=serial-1 where serial > DELETED.serial;
END$$
DELIMITER ;
在删除时,我收到db.DELETED
不存在的错误。任何人都可以建议我在哪里错了。
答案 0 :(得分:0)
您应该引用已删除行的旧值。在OLD
;
DELETED
DELIMITER $$
CREATE TRIGGER arrange_serial
AFTER DELETE ON db.table
FOR EACH ROW
BEGIN
UPDATE db.table set serial=serial-1 where serial > OLD.serial;
END$$
DELIMITER ;