Re: Can SQL return a threaded-comment-view result set? - Mailing list pgsql-novice

From Tom Lane
Subject Re: Can SQL return a threaded-comment-view result set?
Date
Msg-id 27236.1065106397@sss.pgh.pa.us
Whole thread Raw
In response to Can SQL return a threaded-comment-view result set?  (mvppetlab@yahoo.com (Chris))
Responses Re: Can SQL return a threaded-comment-view result set?
List pgsql-novice
mvppetlab@yahoo.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

pgsql-novice by date:

Previous
From: "Williams, Quinton L"
Date:
Subject: PostgreSQL and .NET
Next
From: Joe Conway
Date:
Subject: Re: Can SQL return a threaded-comment-view result set?