我在使用phpmyadmin设置mysql数据库触发器时遇到问题。这是扳机
DELIMITER //
CREATE TRIGGER triggerName
AFTER INSERT ON `tableToMonitor` FOR EACH ROW
BEGIN
DECLARE `recordExists` TINYINT;
IF NEW.`field1` = "stringValue" THEN
SELECT COUNT(*)
INTO `recordExists`
FROM `table1`
WHERE (`field2` = NEW.`field2`) AND (`field3` = NEW.`field3`);
IF recordExists = 1 THEN
UPDATE `table1`
SET `field4` = 1
WHERE (`field2` = NEW.`field2`) AND (`field3` = NEW.`field3`);
ELSE
INSERT INTO table1 (`field2`, `field3`, `field4`, `field6`, `field7`, `field8`, `field9`)
VALUES (NEW.`field2`, NEW.`field3`, 1, 0, 0, 0, 0);
END IF;
END IF;
END //
当我试图设置触发器时,出现以下错误:
1064-您的sql语法有错误;在第20行“//”附近,检查与mysql服务器版本相对应的手册,以获得正确的语法
我找不到错误,有人能帮我吗?
暂无答案!
目前还没有任何答案,快来回答吧!