我正在尝试在mysql dbms中编写一个after触发器,但它不起作用。目标是在插入事件之后删除除最新行(插入行中的行)之外的所有行。请我的错误在哪里?
BEGIN
DECLARE num integer;
DECLARE num2 integer;
SELECT COUNT(*) INTO num FROM TABLENAME;
SELECT MAX(temps) INTO num2 FROM TABLENAME;
IF num > 3 THEN
DELETE FROM TABLENAME WHERE temps < num2;
END IF;
END