Recursive select

From: "Jason Kwok" <jason(at)newhonest(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Recursive select
Date: 2001-10-26 06:57:18
Message-ID: 00af01c15deb$74289940$0201a8c0@newhonest.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I have a table :

MyID parentID
================
5 6
6 7
3 13
7 3

Is there any simple select statement that can get all rows with MyID = 5 and
all its parents?
That means 5's parenet is 6, 6's parent is 7, 7's parent is 3.....

Jason

---
Virus Free
Checked by AVG anti-virus system (http://www.grisoft.com)
Version: 6.0.286 / Virus Database: 152 - Release Date: 2001/10/9

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Dmitry G. Mastrukov Дмитрий Геннадьевич Мастрюков 2001-10-26 06:57:36 Re: GUID in postgres
Previous Message Bhuvan A 2001-10-26 06:14:19 Connecting to different DataBase In PlPgsql Function