List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:October 22 2001 9:37pm
Subject:Re: Tree in SQL
View as plain text  
In the last episode (Oct 22), Daniel _a_ said:
> I have a table in database which describes tree structure of article groups.
> In this table I have:
> 1. group_id - group identifier
> 2. parent_group_id - identifier of parent group
> I need to select history, from top to wanted group.
> I can't change the database design and ofcourse this is MySQL 3.23 database.
> Can somebody help me ?

You'll have to do multiple selects.  Loop:

select parent_group_id from table where group_id = :myid
:myid = parent_group_id

Stop when myid == the ID of the top of the tree.

-- 
	Dan Nelson
	dnelson@stripped
Thread
Tree in SQLDaniel Łaś22 Oct
  • RE: Tree in SQLSteve Meyers23 Oct
    • ODP: Tree in SQLDaniel Łaś23 Oct
      • RE: Tree in SQLSteve Meyers23 Oct
  • Re: Tree in SQLDan Nelson24 Oct