Is there a way to delete multiple records from three tables at once in one query?
categories:
id, name
sub_categories:
id, category_id, name
items:
id, subcategory_id, name
I have id
of the category that I need to delete. For example, 5
The SQL query must delete the category with that id
.
categories.id = 5
Also, it must delete all the subcategories from that category.
sub_categories.category_id = categories.id
And finally, delete all items from those subcategories that where removed in step 2.
items.subcategory_id = sub_categories.id