且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除所有MySQL外键约束没有失败的地方

更新时间:2023-01-20 11:33:42

您必须LEFT JOIN引用表并添加一个条件,表明该表中缺少该行.

You have to LEFT JOIN the referencing table and add a condition saying that the row is missing in that table.

例如:

DELETE a FROM a
LEFT JOIN b ON b.a_id = a.id
WHERE b.a_id IS NULL;