On Mon, 5 Mar 2001 10:13:29 -0600
"Johnny Withers" <[EMAIL PROTECTED]> wrote:
> Well, if you have everything setup right.. this is easy to do in SQL.
>
> Lets say you have your root table:
[...]
>
> and your sub categories:
[...]
>
> and your final category:
[...]
>
> now you can simply join all these tables..
I have a single table that contains all the sections, so I would not have a
limit to how many sections and subsections that I can create. Yes, it would be
easy to do a join on those three tables, but that doesn't scale very well since
I would have to add a table if I wanted the ability to go deeper than two
subsections.
Here is the current structure of the table:
+------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------------------+------+-----+---------+----------------+
| section_id | tinyint(3) unsigned | | PRI | NULL | auto_increment |
| parent_id | tinyint(3) unsigned | | | 0 | |
| name | varchar(100) | | | | |
| descript | mediumtext | YES | | NULL | |
| is_hidden | tinyint(4) | | | 0 | |
| modified | timestamp(14) | YES | | NULL | |
+------------+---------------------+------+-----+---------+----------------+
They link together by section_id's and parent_id's. With what I described
below, the section record would contain:
(Root)
|
|==> section_id: 0 <--------|
|==> parent_id: 0 |
| |
+----Sports Products |
| | |
| |==> section_id: 2 <---|----|
| |==> parent_id: 0 ----| |
| | |
| +----Golf |
| | | |
| | |==> section_id: 3 |
| | |==> parent_id: 2 ----|
| | |
| +----Fishing Products |
| | | |
| | |==> section_id: 4 |
| | |==> parent_id: 2 ----|
> Here's what I have:
> I have a table that among others, have fields called 'section_id' and
> 'parent_id'. The section_id is the id of the "self" section,
> and the parent_id is the id of the section that "owns" the self section.
> (It's sort of like a filesystem where one directory has
> subdirectories, and so on)
>
> Here's what I'm trying to do:
> I want to start with one section, and go down the tree of sub-sections,
> picking up information about them on the way.
>
> Example:
> I want to start at the "root" section, and follow down one of it's
> sub-sections.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php