Re: Can SQL return a threaded-comment-view result set?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: mvppetlab(at)yahoo(dot)com (Chris)
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Can SQL return a threaded-comment-view result set?
Date: 2003-10-02 14:53:17
Message-ID: 27236.1065106397@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

mvppetlab(at)yahoo(dot)com (Chris) writes:
> My question is: is it possible to use pure SQL to return a result set
> that would make rendering a threaded view like the above really easy?

What you're really after is a tree structure. This is relatively easy
to do with Oracle's CONNECT BY or SQL99's WITH, neither of which we have
in Postgres (yet). I think in bog-standard SQL92 you can't readily do
it without adding some additional fields to the table.

I highly recommend you buy a copy of Joe Celko's "SQL For Smarties".
He has two whole chapters on different ways to handle trees in SQL.

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Joe Conway 2003-10-02 15:23:31 Re: Can SQL return a threaded-comment-view result set?
Previous Message Bruno LEVEQUE 2003-10-02 14:21:32 Re: erro while loading shared libraries: can't open libpq.so.3