Search Postgresql Archives

Selecting tree data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux