[SQL] retrieving all rows from a tree in one select - how ?

2002-08-09 Thread h012
Hi, I realize that a relational database may not be ideal for storing (and retrieving) tree-like strucutres, but it looks like you guys are doing with PostgreSQL the impossible anyway. Having table t of all nodes: CREATE SEQUENCE nodeIDseq START 1; CREATE TABLE t( id int

Re: [SQL] retrieving all rows from a tree in one select - how ?

2002-08-09 Thread Adam Erickson
I'll be curious to see the responses to this. I myself deal with this same situation every day. Although we're currently using MySQL but moving it to postgres (which is why I'm on these lists..) -- select a tree starting with node 1234 and all its descendants: SELECT * FROM t WHERE id=1234

Re: [SQL] retrieving all rows from a tree in one select - how ?

2002-08-09 Thread Josh Berkus
Guys, Check out Joe Celko's two chapters on tree structures in the 2nd edition of SQL for Smarties. It's pretty comprehensive. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end of broadcast)--- TIP 6: Have you searched our list

Re: [SQL] retrieving all rows from a tree in one select - how ?

2002-08-09 Thread Oleg Bartunov
folk, have you looked at ltree ? http://www.sai.msu.su/~megera/postgres/gist/ltree/ Regards, Oleg On Fri, 9 Aug 2002, Adam Erickson wrote: I'll be curious to see the responses to this. I myself deal with this same situation every day. Although we're currently using MySQL but