I have 3 tables (mysql)
products
product_id, title
categories
category_id, parent_id, title
products_categories
product_id, category_id
The depth of the category tree is unknown. Is there a way to know with one query which categories have categories etc. that have products?