i have "product" table it contains all products details .
product_id product_type_id internal_name
1001 finishedgood nokia
1002 rawmaterial chip
1003 subassembly diaplay
1004 rawmaterial displaybase
it means to make nokia phone( finishedgood) company needs
chip(rawmaterial) , display(subassembly) . to make display(subassembly) it again needs
displaybase ( rawmaterial)
Now "productassoc" table details
product_id product_id_to
1001 1002
1001 1003
1003 1004
my question : i want to retrive all objects needed for nokia manufacturing
this query returns level 1 goods be needed .( i want to display raw materials needed for
subassembly also )
query:
select pa.product_id,pa.product_id_to,p.product_type_id,p.internal_name
from product p,
product_assoc pa
where p.product_id=pa.product_id_to and pa.product_id=1001
o/p
product_id product_id_to product_type_id internal_name
1001 1002 rawmaterial chip
1001 1003 subassembly display
-----
i want to display rawmaterials needed for subassembly also .
means , my query should return all the rawmaterials and subassemblys needed to make
finishedgood. and also rawmaterials needed for subassemblys.
this is only an sample . i had around 100 components for a product.