Recursive select - Mailing list pgsql-sql

From Martin Smetak
Subject Recursive select
Date
Msg-id 009301c0e368$589c0de0$0b01010a@no9.cz
Whole thread Raw
Responses Recursive select
List pgsql-sql
Hi all!

Anyone know if it's possible to make a recursive select from a table ?
My problem: I got a table of "some categories" which all points to its
parrent one(tree)...shown below. And I want to select all names of
parrent categories of one child, lets say "fast[4]". Now I'm solving that
with
many SQL queries like : "SELECT main_id FROM cat WHERE id=4;"....but I would
like to optimize this.

Anyone can help or point me to a way ??

Thanks a lot,Minca

Table : CAT
ID        |        Main_id        |    Name
=========================
1                    0                    Car
2                    1                    Crash
3                    1                    Wash
4                    3                    Fast
5                    1                    Second_hand
6                    0                    House
7                    3                    Slow
....etc

*(root)[0]
-Car[1]       -Crash[2]       -Wash[3]           -Fast[4]           -Slow[7]       -Second hand[5]
-House[6]




pgsql-sql by date:

Previous
From: "Michael Richards"
Date:
Subject: index/join madness
Next
From: jdassen@cistron.nl (J.H.M. Dassen (Ray))
Date:
Subject: Re: Truncation of char, varchar, bit, varbit types (fwd)