Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bill-of-Material processing 1

Status
Not open for further replies.

rmuller

Programmer
Nov 30, 2001
14
NL
I searched the Internet and looked into my SQL books, but could not find the answer, so i hope someone here can help me!
I have a table like this (simplified):
Code:
CREATE TABLE Products (
    ProductId COUNTER CONSTRAINT ProductsPK PRIMARY KEY,
    ProductCode CHAR(8) NOT NULL,
    ParentId LONG CONSTRAINT ProductFK1 
        REFERENCES Products (ProductId),
    LevelCode BYTE);
For this table i need a 'exploded view' and an 'imploded view'.

Exploded view: all products that are decendants of the given product.
Imploded view: all ancestors (parents, grandparents and so on, up to and including a product with LevelCode=0).

Any SQL guru who can help me?
Thanks in advance

Ronald
 
Visio (if you have it) has a good example of this type of query, using an organization structure.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
tnx michael (again!)

i do not have visio (i use smartdraw), can you post the query, it will be VERY helpfull for me, so thanks in advance!
 
 
thanks terry!

very helpfull, i implemented celko's nested set approach. Works great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top