Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 3E4EF475ACE for ; Wed, 19 Jun 2002 03:30:23 -0400 (EDT) Received: from port50-2.unice.fr (ad-port53-2.unice.fr [134.59.53.249]) by postgresql.org (Postfix) with ESMTP id 2CE7C475AEC for ; Wed, 19 Jun 2002 03:30:22 -0400 (EDT) Received: by port50-2.unice.fr (Postfix, from userid 1000) id 2FB432FBED; Wed, 19 Jun 2002 09:30:21 +0200 (CEST) Date: Wed, 19 Jun 2002 09:30:21 +0200 To: pgsql-sql@postgresql.org Subject: Help with a "recursive" query Message-ID: <20020619073021.GA2374@port50-2.unice.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.28i From: alet@unice.fr (Jerome Alet) X-Archive-Number: 200206/238 X-Sequence-Number: 8203 Hi, I've got a table like this : id parent description 01 00 xxxxxx 02 00 xxxxxx 03 01 xxxxxx 04 02 xxxxxx 05 01 xxxxxx 06 05 xxxxxx 07 03 xxxxxx 08 07 xxxxxx 09 00 xxxxxx 10 02 xxxxxx I want to get all tuples which have id=01 as their parent or ancestor, i.e. : 03, 05, 06, 07, 08 this to represent a sort of n-tree : 01 / \ / \ / \ 03 05 / \ / \ / \ 07 06 | | | 08 this example is simple because each node has at most one child, but in my real data there's no such limit. any idea ? thanks in advance Jerome Alet