Selecting tree data

From: "Pat Maddox" <pergesu(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Selecting tree data
Date: 2007-10-25 23:13:05
Message-ID: 810a540e0710251613t4ffbcb84h76b045568718066b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'd like to store some tree data in my database. I want to be able to
sort the data but maintain a tree structure. So for example, if I
order by a timestamp, I should get

- parent1
* child1
* child2
* child3
- parent2
* child4
* child5

and if I reverse the sort order, I get

- parent2
* child5
* child4
- parent1
* child3
* child2
* child1

Is it possible to pull all the data like that with one query? How do
I need to structure the table, and what query do I have to run in
order to make it happen?

Pat

Responses

Browse pgsql-general by date

  From Date Subject
Next Message jimmy Zhang 2007-10-26 01:31:47 [ANN]VTD-XML 2.2
Previous Message Ralph Smith 2007-10-25 22:59:58 Re: 2 versions running & using pg_dumpall