Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
acko
Yak Posting Veteran
52 Posts |
Posted - 2003-07-25 : 09:00:07
|
| Hello everybodyHere is my problemI have two tables.First is Products and second is ProductsPart.Products:CREATE TABLE [Products] ( [ID] [char] (16), [NAME] [char] (40))ProductsPart:CREATE TABLE [ProductsPart] ( [ID] [char] (16), [IDPOD] [char] (16), [QUANTITY] [smallint])All products are in the products table.Some of products are made of the other products which are also in the products table. From which products the product is made you know with ProductsPart table because IDPOD field shows product from which is made product which ID is ID.Let's say that Product1 is made from Product2 and Product3If I want to see from which product Product1 is made I will write this query:SELECT P.ID, P.NAMEFROM Products P JOIN ProductsPart PP ON P.ID = PP.IDPODWHERE PP.ID = 'Product1'I will get this results:ID2 Product2ID3 Product3But what if the Product3 is made of the others products(Product4, Product5) and so on...(Product4 = Product6 + Product7)...How can I make query get this results?ID2 Product2ID3 Product3ID4 Product4ID6 Product6ID7 Product7ID5 Product5Thanks very muchAlex |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-07-25 : 09:46:21
|
| Got to the home page and look up More trees and hierarchies...What happens if a Product is not made up of any other products?Also how many levels deep do you go?Are the Products entered through OLTP or are they append in BATCH?Brett8-) |
 |
|
|
acko
Yak Posting Veteran
52 Posts |
Posted - 2003-07-25 : 10:21:03
|
Thanks very muchquote: Got to the home page and look up More trees and hierarchies...What happens if a Product is not made up of any other products?Also how many levels deep do you go?Are the Products entered through OLTP or are they append in BATCH?Brett8-)
|
 |
|
|
|
|
|