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!

Self Join Question

Status
Not open for further replies.

Bertramp

Technical User
Dec 12, 2006
11
GB
Hi People,

I have a table containing category and another one containing products - each product is has a reference to a category - each category has a field defining a parent id - now this is what i want to do

I would like to have each of the products listed with a field displaying the hierarchy the product belongs to - e.g systems:Desktop Computers:Dell

Thanks

Bert
 
For a self join you need 2 instances of the table with different aliases.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yes - i do understand that - but my confusion is - how many instances do i add to get all node information in a field for a current record - e.g. the current record shows a product called computer the field describing it should be

business:IT:Systems:Desktop | Computer

the first field would describe that the product computer belongs to the desktop category which is a child of the Systems category which in turn is a child of IT and IT is a child node of business

Regards

Bert
 
Use left outer joins and as many instances of the category table than the deepest level.
I don't know an easy way to do recursive SQL ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top