Alias Join Table

From: Keith Gray <keith(at)heart(dot)com(dot)au>
To: SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Alias Join Table
Date: 2001-10-04 23:47:24
Message-ID: 3BBCF50C.D3BFAF4F@heart.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

If I have the following 'Hierachy' table...

Child | Parent
--------------
1 | 0
2 | 1
3 | 1
4 | 3
5 | 4
6 | 3
7 | 4

How do I return a list 5,4,3,1 ?

SELECT a.Child FROM Hierachy AS a, Hierachy AS b
WHERE a.Parent = b.Child
AND a.Child = 5;

... is obviously a bit simplistic in my approach.

--
Keith Gray

Technical Development Manager
Heart Consulting Services P/L
mailto:keith(at)heart(dot)com(dot)au

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Keith Gray 2001-10-04 23:50:49 Re: Beginner's List
Previous Message Maher, Christopher W 2001-10-04 22:53:46 SQL CONSTRAINTS - Constraining time values from two attributes on a table.