mysql delete and foreign key constraint

Posted by user121196 on Stack Overflow See other posts from Stack Overflow or by user121196
Published on 2010-05-05T00:41:58Z Indexed on 2010/05/05 0:48 UTC
Read the original article Hit count: 283

Filed under:
|

I'm deleting selected rows from both table in MYSQL, the two tables have foreign keys. delete d,b from A as b inner join B as d on b.bid=d.bid where b.name like '%xxxx%';
MYSQL complains about foreign keys even though I'm trying to delete from both tables:

Error: Cannot delete or update a parent row: a foreign key constraint fails (yyy/d, CONSTRAINT fk_d_bid FOREIGN KEY (bid) REFERENCES b (bid) ON DELETE NO ACTION ON UPDATE NO ACTION)


what's the best solution here to delete from both table?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about delete