Deleting from multiple tables with foreign constraints
问题 I am trying to delete from multiple tables. Here's what my tables look like A_has_B ---- B ---- C_has_B (many to many) (many to many) I am trying to delete all rows from A_has_B, B and C_has_B given the ID of a record in B. I am using MySQL with the innodb storage engine with foreign keys defined for A_has_B and C_has_B referencing the IDs in B. I am trying to perform my delete like so: DELETE A_has_B.*, C_has_B.*, B.* FROM A join B on (B.B_id = A.B_id) join C on (C.B_id = B.B_id) where B.B