Anything like Oracle's "connect by" SQL? - Mailing list pgsql-novice

From Tim Wright
Subject Anything like Oracle's "connect by" SQL?
Date
Msg-id 4.1.20031001213414.00b3ed58@pop.freeserve.net
Whole thread Raw
Responses Re: Anything like Oracle's "connect by" SQL?  (Nabil Sayegh <postgresql@e-trolley.de>)
Re: Anything like Oracle's "connect by" SQL?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
Hi,

Oracle has a rather handy system for recursing through a table hierarchy.
To give an example, if we had a table representing Companies, with three
fields: company_id, parent_company_id and company_name, you could use the
following SQL to get all parents (and parent of parents, etc) of company_id
1234 like this:

select company_name from Company
connect by company_id = prior parent_company_id
start with company_id = 1234

(My sincere apologies if I'm teaching people to suck eggs - this is my
first post to the list, so for all I know you're all Oracle gurus!)

Is there any kind of function like this in PostgreSQL, or other way to
easily simulate it? I'm currently designing a database which will require a
certain amount of parent-child relationships, and whilst in Oracle I know
the SQL would be simple, I'm not sure how easy it will be without using
"connect by"...

Any help gratefully received!

Cheers,

Tim.

pgsql-novice by date:

Previous
From: Manfred Koizar
Date:
Subject: Re: SELECT syntax question - combining COUNT and DISTINCT
Next
From: Nabil Sayegh
Date:
Subject: Re: Anything like Oracle's "connect by" SQL?