in reply to Pulling out information for MySQL

Seems like there is a flurry of database questions today - most of which aren't really perl issues at all...

To somewhat answer the question - this known as a "master-detail" problem in SQL. To achieve what you want you need to think of the database, and of how the various items in it relate to each other.

If you want maximum flexibility you could do something like this:

create table category ( id numeric(9,0) -- autoincrement , parent_id numeric(9,0) null , name varchar(30) , level int -- might not be needed) , ... other columns )
Note - I don't know what the correct syntax for an auto-increment column is in MySQL...

Anyway - now you have a table that can represent any depth of category nesting.
The downside is that getting the full data in the right order can become an "interesting" exercise.

The table above is just an idea to get you thinking - not necessarily the correct solution to your problem.

Michael