我遇到了从多个表中删除的问题。
DELETE FROM categories, products
WHERE categories.category_id = products.category_id
AND categories.category_id = 4;
有人能发现我所犯的错误吗? 我收到了错误代码:1064
答案 0 :(得分:0)
您可以像删除级联一样在产品表上创建外键。然后,当您删除类别时,产品表引用也将被删除
DELETE FROM categories WHERE
categories.category_id = 4;