I think a self join is what I need.
I have a table with three columns:
CAT_ID int identity primary key
CAT_NAME varchar(20)
CAT_PARENT int
cat_parent is a primary key which references cat_id (yep, a self-referencing table). I'm doing this because I want to generate a crumb-trail kinda like Yahoo, where it shows the category you're in and then adds the subcategory the deeper you go. On the given page, I'll have the cat_id for the lowest subcategory. I need to get a list of the category names (cat_name) that complete the "path" from the main category to that lowest subcategory.
Can this be done via one SQL statement?
thanks ------------------------------------
"Unclean beast! Get thee down! Be thou consumed by the fires that made thee!" - Brother Jacobus in Dragonslayer
I have a table with three columns:
CAT_ID int identity primary key
CAT_NAME varchar(20)
CAT_PARENT int
cat_parent is a primary key which references cat_id (yep, a self-referencing table). I'm doing this because I want to generate a crumb-trail kinda like Yahoo, where it shows the category you're in and then adds the subcategory the deeper you go. On the given page, I'll have the cat_id for the lowest subcategory. I need to get a list of the category names (cat_name) that complete the "path" from the main category to that lowest subcategory.
Can this be done via one SQL statement?
thanks ------------------------------------
"Unclean beast! Get thee down! Be thou consumed by the fires that made thee!" - Brother Jacobus in Dragonslayer