I have two tables in a DB like below.
Catagories
----+---------------------------------+-------------
id | name | parent |
----+---------------------------------+-------------
1 | Home | 0 |
2 | catagory1 | 1 |
3 | catagory2 | 1 |
4 | catagory3 | 1 |
5 | sub_catagory1 | 2 |
6 | sub_catagory1 | 4 |
7 | sub_sub_catagory2 | 5 |
----+---------------------------------+------------
Products
-----+----------------+-------------------+
id | name | catagory_id |
----+----------------+--------------------+
1 | shoes | 2 |
2 | soap | 7 |
3 | comb | 6 |
4 | slippers | 5 |
----+----------------+---------------------+
I want to select products for a specific catagory & results should include its children categories products too(recursively).
ex:
input => catagory 1
output=>
shoes (products from catagory 1)
slippers (products from sub_catagory1 )
soap (products from sub_sub_catagory1 )
Please help mee........!!
Catagories
----+---------------------------------+-------------
id | name | parent |
----+---------------------------------+-------------
1 | Home | 0 |
2 | catagory1 | 1 |
3 | catagory2 | 1 |
4 | catagory3 | 1 |
5 | sub_catagory1 | 2 |
6 | sub_catagory1 | 4 |
7 | sub_sub_catagory2 | 5 |
----+---------------------------------+------------
Products
-----+----------------+-------------------+
id | name | catagory_id |
----+----------------+--------------------+
1 | shoes | 2 |
2 | soap | 7 |
3 | comb | 6 |
4 | slippers | 5 |
----+----------------+---------------------+
I want to select products for a specific catagory & results should include its children categories products too(recursively).
ex:
input => catagory 1
output=>
shoes (products from catagory 1)
slippers (products from sub_catagory1 )
soap (products from sub_sub_catagory1 )
Please help mee........!!