i have two tables
Table1 : Categories ,
Columns : id , parent_id , name
Table2 : products ,
Columns : id , product_name , category_id , subcategory_id , sale_wanted
Here is the detail
A category can have multiple subcategories id. Parent id 0 means it s a category and parent id != 0 means it is a subcategory. Now each product is related to a subcategory. I need to display the names of category and total subcategories count related to each category.
sale 0 means the product is for sale and 1 means it is required.
Now i need this.
1.Display all categories and count of subcategories related to each category where the products related to category are for sale.