Mysql delete and foreign key constraint

I delete the selected rows from both tables in MYSQL, the two tables have foreign keys. delete d, b from A as b is the inner join of B as d on b.bid = d.bid where b.name is like '% xxxx%';
MYSQL complains about foreign keys, although I am trying to remove from both tables:

Error: cannot delete or update parent line: foreign key constraint ends with an error ( yyy/d, CONSTRAINT fk_d_bidFOREIGN KEY ( bid) LINKS b( bid) ON DELETE NO UPDATE ACTIONS NO ACTIONS)


what is the best solution here to remove from both tables?

+3
source share
2 answers

ON DELETE CASCADE - , , "" .

, , CASCADE - . DELETE, .:)

. .

+6

, ,

, 2 ,

B, IN ( A, "% xxxx%" );

A, "% xxxx%";

0

Source: https://habr.com/ru/post/1744070/


All Articles