recursive

From: Julien Cadiou <julienc(at)vicnet(dot)net(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: recursive
Date: 1999-11-25 01:09:48
Message-ID: 3.0.3.32.19991125120948.010b4d80@mail.vicnet.net.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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/

Attachment Content-Type Size
unknown_filename text/enriched 1.3 KB

Browse pgsql-sql by date

  From Date Subject
Next Message Julien Cadiou 1999-11-25 01:15:54 recursion
Previous Message maxsbox 1999-11-24 18:14:11 Re: pgsql-sql-digest V1 #422