Thread: Alias Join Table

Alias Join Table

From
Keith Gray
Date:
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@heart.com.au


Re: Alias Join Table

From
"Josh Berkus"
Date:
Keith,

There are a number of posts and papers on tree structures , both in the
SQL list archives, and on Roberto Mello's resources at
techdocs.postgresql.org.

-Josh


______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco