i am trying to get product's name
and categ_id
. I have two tables that are,
product_template
categ_id name
7 Nokia classic
7 Nokia lumia
8 samsung s3
6 huawai
this table have product
that i want to get,
product_category
id name parent_id
6 phones 3
7 nokia 6
8 samsung 6
this table shows that which product is under phone > nokia
and phone > samsung
or product can be directly under phone as shown under,
like,
phones > huawai
phones > nokia > Nokia classic
phones > nokia > Nokia lumia
phones > samsung > samsung s3
query i am using is,
select pt.categ_id,pt.name from product_template pt inner join product_category pc on
pt.categ_id=pc.id where pc.parent_id='6'
it is showing all products except huawai
???
query should run like that it can get products that are under phone
directly and under this way phone > nokia > Nokia Classic
Thanks in advance for your suggestions.