X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7DE0D475458 for ; Thu, 17 Apr 2003 15:08:48 -0400 (EDT) Received: from fish.net (codepoets.co.uk [81.5.147.148]) by postgresql.org (Postfix) with ESMTP id BAF76475458 for ; Thu, 17 Apr 2003 15:08:22 -0400 (EDT) Received: by fish.net (Postfix, from userid 612) id A7F541E1A; Thu, 17 Apr 2003 20:08:17 +0100 (BST) Received: from haddock.fish.net (haddock.fish.net [192.168.0.2]) by fish.net (Postfix) with ESMTP id E2BD31E15 for ; Thu, 17 Apr 2003 20:08:14 +0100 (BST) Received: by haddock.fish.net (Postfix, from userid 1000) id D92DEED2B; Thu, 17 Apr 2003 20:08:14 +0100 (BST) Date: Thu, 17 Apr 2003 20:08:14 +0100 From: David Goodwin To: pgsql-sql@postgresql.org Subject: Re: reversion? Recursion question Message-ID: <20030417190814.GA4905@codepoets.co.uk> References: <1050451222.13093.22.camel@aragorn.vpop.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1050451222.13093.22.camel@aragorn.vpop.net> User-Agent: Mutt/1.4.1i X-Operating-System: Slackware Linux 8.1 + - 2.4.20-ck6 X-Spam-Status: No, hits=-37.3 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,NO_DNS_FOR_FROM, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, SIGNATURE_SHORT_SPARSE,USER_AGENT_MUTT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/286 X-Sequence-Number: 12987 Brad Hilton wrote : > On Tue, 2003-04-15 at 15:41, Patrick Hatcher wrote: > > Hello, > > For lack of a better title, I need to a reverse recursion. Where I have > > the parent ID, but then I need to find all it's children, grandchildren, > > great-grandchildern, etc for the parent-id. I guess this would be like a > > directory and all its sub-directories. > > You may want to look at another way of doing this. Joe Celko gives an > example of "nested sets" which allows you to select tree-like sets from > your database very efficiently. His book "SQL for Smarties" has a > chapter on this, or google for "celko sql tree" and you'll find some > articles he's written on it. Here's a link to one: > http://www.intelligententerprise.com/001020/celko.shtml. Thanks for that! It's going to improve my life no end! David. -- David Goodwin [ dof at codepoets dot co dot uk ] [ http://www.codepoets.co.uk ]