List:General Discussion« Previous MessageNext Message »
From:Steve Meyers Date:October 23 2001 4:53pm
Subject:RE: Tree in SQL
View as plain text  
I understand that you only have one table.  The query I gave you joins the same table
against itself, and aliases it to a, b, and c.  The only question was whether the depth is
always the same.
Steve Meyers

> Hi
> I have one table and the depth is not always the same.
> Anyway thanks :)
> > If the depth of the tree is always the same, it is actually
> > fairly easy.  For instance, if there are three levels:
> >
> > SELECT c.group_id FROM table a, table b, table c WHERE a.group_id
> > = 12345 AND b.group_id = a.parent_group_id AND c.group_id =
> > b.parent_group_id
> >
> > If you don't know the depth, you'll have to do a recursive search
> > (keep on querying for the next parent until you run out of parents).
> >
> > Steve Meyers

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