在我的活动中,我有:
UPDATE Xdb.shop_product_m2m as m2m
SET m2m.expired=1 WHERE m2m.expires <= now();
我在“shop_product_m2m”表的更新触发器中尝试了这个:
SET NEW.modified = NOW();
IF NEW.expired =1 OR NEW.expired = "1" THEN
SET NEW.expired = 1;
ELSE
SET NEW.expired = 0;
SET NEW.expires =ADDDATE(NEW.modified, INTERVAL 15 DAY);
但是'IF NEW.expired =1 OR NEW.expired = "1" THEN'行中的测试彻底失败了。
为什么我失败了?
提前致谢..
编辑:表“shop_product_m2m”的 DDL 以获取回复的附加信息
create table if not exists Xdb.shop_product_m2m(
id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
created datetime NOT NULL,
modified datetime NOT NULL,
expires datetime NOT NULL,
shop int NOT NULL,
product int NOT NULL,
price decimal(13,2),
instock boolean NOT NULL DEFAULT 1,
expired boolean NOT NULL DEFAULT 0,
burgainable boolean NOT NULL DEFAULT 1,
FOREIGN KEY (shop) REFERENCES shop(id) ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (product) REFERENCES product(id) ON DELETE CASCADE ON UPDATE CASCADE
);