MySQL触发器在某些条件下阻止INSERT

DROP TRIGGER `before_insert_order_trigger`;
CREATE  TRIGGER `before_insert_order_trigger` BEFORE INSERT ON `order_info`
FOR EACH ROW BEGIN
IF DATE(new.from_date) >= DATE(new.to_date)
THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = "from_date cannot be later than to_date";
END IF;
END;

你可能感兴趣的:(mysql,触发器)