Received: from mail.vicnet.net.au (merri.vicnet.net.au [203.10.72.9]) by hub.org (8.9.3/8.9.3) with ESMTP id UAA57494 for ; Wed, 24 Nov 1999 20:09:51 -0500 (EST) (envelope-from julienc@vicnet.net.au) Received: from jcadiou (dhcp76-71.slv.vic.gov.au [202.137.76.71]) by mail.vicnet.net.au (Postfix) with SMTP id 7D24AF8056 for ; Thu, 25 Nov 1999 12:09:47 +1100 (EST) Message-Id: <3.0.3.32.19991125120948.010b4d80@mail.vicnet.net.au> X-Sender: julienc@mail.vicnet.net.au X-Mailer: QUALCOMM Windows Eudora Pro Version 3.0.3 (32) Date: Thu, 25 Nov 1999 12:09:48 +1100 To: pgsql-sql@postgresql.org From: Julien Cadiou Subject: recursive Mime-Version: 1.0 Content-Type: text/enriched; charset="us-ascii" Hi, I'm trying to get my head around a simple problem but can't get it unless I expect too much of SQL. I'm building a links indexing application and want to maintain full relationality in the database. My table is as follows: id|name |owner --+--------------------+----- 1|Leisure | 0 2|Business | 0 5|Men's tennis lessons| 7 4|Finance | 2 10|Banks | 4 6|Stock Market | 4 8|Outdoors | 0 7|Men's Tennis | 3 9|Racket Sports | 3 3|Sports | 8 Each category has an id, a name and an owner. Subcategories are owned by other categories (the owner's id being the owner value) etc ... which is the relation between id and owner. By knowing, for example, the primary key of Men's tennis lessons (5), I want to extract all categories in its path, all the way to the top, so as to get, in this case: Outdoors > Sports > Men's Tennis > Men's Tennis Lessons It seems to be a simple thing but after man joins and attempts at recursions, I still can't find it ... Any ideas ? Julien CADIOU Database Administrator VICNET - Victoria's network Phone: (03) 9669 9710 Fax: (03) 9669 9805 Web: http://www.vicnet.net.au/