我将此代码输入mysql,但它出错了:
CREATE TRIGGER delete_vote_topic BEFORE DELETE ON vote_topic
FOR EACH ROW BEGIN
DELETE FROM vote_option WHERE vote_topic_id = OLD.id;
DELETE FROM vote_option_votes WHERE vote_topic_id = OLD.id;
END;
错误是:
#1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在第3行的''附近使用正确的语法
有人知道我做错了吗?
答案 0 :(得分:2)
尝试使用分隔符
delimiter |
CREATE TRIGGER delete_vote_topic BEFORE DELETE ON vote_topic
FOR EACH ROW
BEGIN
DELETE FROM vote_option
WHERE vote_topic_id = OLD.id;
DELETE FROM vote_option_votes
WHERE vote_topic_id = OLD.id;
END;
|