i have two table like this: tbl1-
ID | post_id | terms_id
------------------------
1 4001 2
2 4001 1
3 4001 3
4 4002 5
5 4002 2
tbl2-
terms_id | taxonomy_id | taxonomy
----------------------------------
1 30 category
2 33 keywords
3 42 location
4 52 category
5 32 category
I want two delete tbl1 where post_id = 4001 and (terms_id = 'category') from tbl2.
i can't write this query how to set relation tbl1 terms_id and tbl2 terms_id
and tbl2 terms_id should be 'category'.
i tried to use inner join but it delete both table data or it shows error. i just need to delete from tbl1 data.
This is my query:
DELETE FROM tbl1
INNER JOIN tbl2 ON tbl2.terms_id = tbl1.terms_id
WHERE tbl2.taxonomy = 'category' AND tbl1.post_id = 4001