my question may seem strange. But I have a question, how should I do a JOIN on a table for the following purpose:
I have a table called categories
.
I have another pivot table called categories_products
Regularly I do a left join to get the categories of one product.
Now, after several month, there are some categories deleted from categories
table. I had forgot to put a trigger at that time (that delete all related categories_products
records of the deleted cat). I want to delete any record (which now is considered to be unused) from categories_products
where its categories item is deleted (does not exist). What query should I write? Nothing comes to my mind. Thanks