recursive query?

From: CSN <cool_screen_name90001(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: recursive query?
Date: 2004-02-02 21:54:36
Message-ID: 20040202215436.2850.qmail@web40609.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table with these columns:

id, node, parent_node_id

The top-most nodes would have a parent_node_id of
NULL. Is it possible to get a node, and all its parent
nodes, in a single query?

For example, a node might be:

books > computers > databases > oss > postgres

and the rows fetched would be:

1,books,NULL
2,computers,1
3,databases,2
4,oss,3
5,postgres,4

TIA,
CSN

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2004-02-02 22:45:35 Re: Are there commands to enquire about table structure?
Previous Message Matt Davies 2004-02-02 21:49:17 Re: Postgresql 7.3 And Redhat Enterprise 3