I have a database of 30000 products and all products has assigned different categories. There is a separate table for all categories & sub-categories are also stored into same table. The table structure is something like this
Category_mst
category_id_pk, category_name, parent_id
Product_mst
product_id_pk, product_name, category_id_fk (reference to Category_mst->category_id_pk)
Categories are stored upto any number of sub levels. So there can be categories like below
Clothes > Shirts > Kids > Red Color
Products are stored on any level of Category. I want to make a query or a php script that can find out all the Categories that have no Products under it(upto any sub level).
How can I do this ?
Thanks in advance.