DELETE
a,b,c
FROM
sp_movie.movie_db AS a
INNER JOIN sp_movie.movie_time AS b
ON a.Movie_ID = b.Movie_ID
INNER JOIN sp_movie.movie_time AS c
ON c.Movie_ID = a.Movie_ID
WHERE
a.Movie_ID = 29
我正在尝试删除具有Movie_ID = 29
我甚至试过写这个
DELETE a FROM.....
我遇到错误:Error Code: 1451. Cannot delete or update a parent row: a foreign key constraint fails (
sp_movie .
movie_actor , CONSTRAINT
2 FOREIGN KEY (
Movie_ID ) REFERENCES
movie_db (
Movie_ID ) ON DELETE NO ACTION ON UPDATE NO ACTION)
答案 0 :(得分:0)
您可以先执行多个查询并从movie_time
删除行,然后分别删除movie_db
行。在运行上述查询之前,您还可以使用SET foreign_key_checks = 0
。
答案 1 :(得分:0)
我通过为on cascade
和time
表
actors
的外键引用操作来解决此问题