0

I'm running into a problem with deleting from multiple tables.

DELETE FROM categories, products
WHERE categories.category_id = products.category_id 
    AND categories.category_id = 4;

Can anyone spot the mistake that I've made? I'm getting the errorcode: 1064

Kluong
  • 302
  • 3
  • 15

1 Answers1

0

you can make the foreign key on product table as on delete cascade. Then, when you delete category product table references will also be deleted

DELETE FROM categories WHERE  
   categories.category_id = 4;
reptildarat
  • 1,036
  • 2
  • 18
  • 35
Chatz
  • 338
  • 2
  • 10