我做了:
CREATE EVENT test_event_insert_fine
ON SCHEDULE every 1 day
ON COMPLETION PRESERVE
DO
IF (NOW()>=DATE_ADD(select date from loan, interval 3 day)) then
insert into fine(price,date) values(100,NOW());
END IF;
如何插入多行只有一个"插入"根据" IF"?
的条件感谢。
答案 0 :(得分:0)
可能有用的一个选项:
DELIMITER $$
CREATE EVENT `test_event_insert_fine`
ON SCHEDULE EVERY 1 DAY
ON COMPLETION PRESERVE
DO
BEGIN
DECLARE `_NOW` DATETIME DEFAULT NOW();
INSERT INTO `fine` (`price`, `date`)
SELECT 100, `_NOW`
FROM `loan`
WHERE `_NOW` >= DATE_ADD(`date`, INTERVAL 3 DAY);
END$$
DELIMITER ;