If I have a parent table and a child table, is it possible to repeatedly delete rows in them without the “DELETE CASCADE” restriction?
In this example:
create table a(id int primary key);
create table b(id int primary key, a_id int,
constraint fkb foreign key (a_id) references a(id));
Is it possible to do something similar to delete rows in tables a and b ?: - (
delete a, b
from b
inner join a on a.id = b.a_id
where a.id = ?;
Error Code: 1451. Cannot delete or update a parent row: a foreign key constraint fails
(`erasmusu6`.`b`, CONSTRAINT `fkb` FOREIGN KEY (`a_id`) REFERENCES `a` (`id`))
I need multi-line strings, but don't set the ON DELETECASCADE limit . I also need to filter the command DELETEwith the sentence WHERE. Is this possible, or do I need to do as much DELETEas tables in multi-user?
source
share