我尝试通过查询创建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
答案 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 ;