我正在尝试在数据库上创建触发器。我可以让它在 SQL fiddle 中正常工作,但是当我尝试在 Sequal Pro 中创建触发器时,我得到一个错误..
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '' at line 8
这是 SQL 小提琴.. http://sqlfiddle.com/#!2/e849f/1
我使用的过程是在创建架构后在查询窗口中执行以下命令。
CREATE TRIGGER upd_selectoin
BEFORE UPDATE ON main
FOR EACH ROW
BEGIN
IF NEW.state = 3 THEN
UPDATE selection s JOIN main m
ON m.main_id = s.id
SET s.allow = 1, last_update_timestamp = NOW()
WHERE s.id = NEW.main_id;
END IF;
END;