From: Julien Cadiou <julienc@vicnet.net.au>
To: pgsql-sql@postgresql.org
Subject: recursive
Date: Thu, 25 Nov 1999 12:09:48 +1100
Message-ID: <3.0.3.32.19991125120948.010b4d80@mail.vicnet.net.au> (raw)
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 ?
<bold>Julien CADIOU
</bold>Database Administrator
<bold>VICNET</bold> - Victoria's network
Phone: (03) 9669 9710
Fax: (03) 9669 9805
Web: http://www.vicnet.net.au/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: julienc@vicnet.net.au
Subject: Re: recursive
In-Reply-To: <3.0.3.32.19991125120948.010b4d80@mail.vicnet.net.au>
References: <3.0.3.32.19991125120948.010b4d80@mail.vicnet.net.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox