MySQL Forums
Forum List  »  Newbie

Query to display categories and subcategories
Posted by: Luis Delgado
Date: May 06, 2005 10:14AM

Hi Guys,

I have a table with all my categories and subcategories, with the following schema:

id_category | id_parent | name

1 | 0 | category#1
2 | 1 | subcategory#1
3 | 1 | subcategory#2
4 | 2 | subsubcategory#1
5 | 0 | category#2
5 | 5 | subcategory#3
...

All categories have id_parent = '0' and subdirectories have id_parent = the category or subcategory they belong to.

I want to do a simple query that displays categories and all it's nested subcategories in order.

Is it possible to do this with one query or must I make a loop to get them all?
Thanks.

Options: ReplyQuote


Subject
Written By
Posted
Query to display categories and subcategories
May 06, 2005 10:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.