tags:

views:

31

answers:

1

My goal is to achieve a list of parent categories from a nested category the easiest way. Say if I had a site that sold a variety of different products, one of which is a quad core pentium. A feature that I'd be able to display on my webpage is as follows:

Electronics > Computers > CPU's > Intel > Intel Quad Core

The category table that I had in mind is:

id, parent_id, description

Doing a recursive process on the parent_id seems tedious. Is there a preferred way of doing this? Thank you.

+5  A: 

Take a look at http://dev.mysql.com/tech-resources/articles/hierarchical-data.html.
The part you're probably interested in most right now is

Retrieving a Single Path
With the nested set model, we can retrieve a single path without having multiple self-joins
VolkerK
Thanks, very informative.
knarxed