是否可以创建一个带有声明语句的事件调度程序?
我一直在尝试运行此查询但没有任何成功
create event dele on schedule
every 1 day
do
begin
declare c int;
select count(*) into c from purchased;
if(c > 5)
delete from purchased limit 2
end if;
end
是否可以创建一个带有声明语句的事件调度程序?
我一直在尝试运行此查询但没有任何成功
create event dele on schedule
every 1 day
do
begin
declare c int;
select count(*) into c from purchased;
if(c > 5)
delete from purchased limit 2
end if;
end
这是因为您THEN
在IF
. 在此处查看手册
尝试这个:
delimiter |
CREATE EVENT dele
ON SCHEDULE EVERY 1 DAY
DO
BEGIN
DECLARE c INT;
SELECT COUNT(*) INTO c
FROM purchased;
IF(c > 5)
THEN
DELETE FROM purchased LIMIT 2;
END IF;
END |
delimiter ;