I have 2 tables
Table1
id | cat_name
1 | Name1
2 | Name2
3 | Name3
Table2
item_id | item_cat
1 | 1,2
2 | 2
3 | 1,3
4 | 2,3
Now my question is this.
when I remove any data from Table1, i want its referencing id (which is in Table2) to get removed as well. I honestly don't have a clue where to begin or how to search/replace such query.
DELETE FROM Table1 WHERE id = 1;
// then this will delete data in item_id 1 and 3
// the result would be so
// query needed here.
Table2
item_id | item_cat
1 | 2
2 | 2
3 | 3
4 | 2,3
thanks.