in reply to Pulling out information for MySQL
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:
Note - I don't know what the correct syntax for an auto-increment column is in MySQL...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 )
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
|
|---|