I have three tables: categories
, content_info
, and content
.
- The
categories
table contains the category'sid
and the ID of itsparent
category. - The
content_info
contains two columns:entry_id
for the post's ID andcat_id
for the ID of the post's category. - The
content
table contains multiple columns about the post - such asID
,title
, etc.
I have a variable in the URL called parent_id which corresponds to the parent
of a category. I want to list all the POSTS (not CATEGORIES) which belong to a category with a parent
of the parent_id value.
For example, say the parent_id value is 5. Each post might belong to a category with an ID of 20, but that category belongs to the parent category (whose ID is 5). I want to list all the posts who belong to categories with a parent
value of whatever the current parent_id happens to be.
Is there a way of doing this with MySQL joins instead of changing the PHP?