为什么我会得到错误触发?

时间:2014-12-13 15:19:54

标签: mysql sql

我尝试通过查询创建Mysql触发器:

CREATE TRIGGER `Delete Video` AFTER DELETE ON video 
FOR EACH ROW 
BEGIN 
DELETE FROM usersalbumsvideo where id_video = OLD.idVideo; 
DELETE FROM categorytovideo where idVideo = OLD.idVideo; 
END

但我得到错误:

1064 - 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 4

还尝试交换id_video = OLD.idVideo和一个DELETE

1 个答案:

答案 0 :(得分:0)

我猜测问题是您的分隔符,查看this页面我认为您的查询应该是:

delimiter //
CREATE TRIGGER `Delete Video` AFTER DELETE ON video 
  FOR EACH ROW 
  BEGIN 
  DELETE FROM usersalbumsvideo where id_video = OLD.idVideo; 
  DELETE FROM categorytovideo where idVideo = OLD.idVideo; 
END;//
delimiter ;