我写了一个触发器,它在 table1 的更新语句后触发。如果根据条件table1中没有行,则更新table2。
CREATE TRIGGER trigger1
AFTER UPDATE ON my_database.table1
FOR EACH ROW
BEGIN
DECLARE cnt int;
IF new.column1 = 1 THEN
SELECT COUNT(1) INTO @cnt FROM my_database.table1
WHERE userID = 1 AND isDeleted = 0;
IF cnt = 0 THEN
UPDATE my_database.table2
SET isDeleted = 1
WHERE userSeqID = new.userID;
END IF
它在第 4 行出现错误,我无法理解问题所在