assuming we have a database category structure like this
# Categories Table
| category_id | parent_category_id | status |
# Products Table
| product_id | category_id |
how do i get the list of products in a category only if the parent_category_id
has an active status = 1
?
i guess i could use some sub-query in the SELECT
statement, but i don't know how! :(
something like:
SELECT p.*, (SELECT * FROM ? WHERE ? ) AS x
FROM products AS p
LEFT JOIN categories AS c ON p.category_id = c.category_id
WHERE ...
AND p.product_id = '?'
AND ...
Thank you in advance for any advice!
NB: i'm using PHP as backend language, just in case i need some sort of data manipulation to pass to the mysql query.