CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ia_att` decimal(3,2) NULL,
`t1` decimal(3,2) NULL,
`t2` decimal(3,2) NULL,
`t3` decimal(3,2) NULL,
`ia_tot` decimal(3,2) NULL,
.....
.....
PRIMARY KEY (`id`),
);
CREATE TRIGGER tg_bi_test
BEFORE INSERT ON test
FOR EACH ROW
SET NEW.s1_ia_tot =
(NEW.s1_t1 + NEW.s1_t2 + NEW.s1_t3 -
LEAST(NEW.s1_t1, NEW.s1_t2, NEW.s1_t3)) / 2 +
CASE
WHEN NEW.s1_ia_att > 95 THEN 5
WHEN NEW.s1_ia_att BETWEEN 81 AND 95 THEN 4
WHEN NEW.s1_ia_att BETWEEN 76 AND 80 THEN 3
WHEN NEW.s1_ia_att BETWEEN 61 AND 75 THEN 2
WHEN NEW.s1_ia_att < 60 THEN 0
SET NEW.s2_ia_tot =
(NEW.s2_t1 + NEW.s2_t2 + NEW.s2_t3 -
LEAST(NEW.s2_t1, NEW.s2_t2, NEW.s2_t3)) / 2 +
CASE
WHEN NEW.s2_ia_att > 95 THEN 5
WHEN NEW.s2_ia_att BETWEEN 81 AND 95 THEN 4
WHEN NEW.s2_ia_att BETWEEN 76 AND 80 THEN 3
WHEN NEW.s2_ia_att BETWEEN 61 AND 75 THEN 2
WHEN NEW.s2_ia_att < 60 THEN 0
--------
--------
END;
创建这样的触发器有什么问题?我想为一张表中的 ia_tot 的七个列创建这个请帮助我这在 mysql 中是否可行