MySQL parent child hierarchy

wxdqz

New Member
Hi all,

I'm new at PHP/MySQL so I'm once again stuck with a problem.

I have a content management thingy where one of the tables (the categories) looks like so:

cat
id | ParentId | Name

So this tabel is self contained: you can have as many sub-sub-sub-sub-sub categories as you want, yet one problem: I'd like to have an overview while the admin is paging through the categories....

If given one particular category id, is it possible to construct some type of MySQL self-join-type statement that will find the parent, and the parent of the parent, etc. until it reaches the top of the hierarchy

Or do I need to look toward a "repeat query" kind of loop with PHP......?

Thanks!
 
Back
Top