Re: Best way to store a threaded message list/tree in SQL - Mailing list pgsql-general

From Johan Nel
Subject Re: Best way to store a threaded message list/tree in SQL
Date
Msg-id gqhhdu$vav$1@news.motzarella.org
Whole thread Raw
In response to Best way to store a threaded message list/tree in SQL  (Mike Christensen <imaudi@comcast.net>)
List pgsql-general
Mike,
connectby() is your friend here.  Do a search on tablefunc in the help file.
> CREATE Table wallposts
> (
>  id uuid NOT NULL,
>  posted timestamp NOT NULL,
>  userid uuid NOT NULL,
>  posterid uuid NOT NULL,
>  parentid uuid NOT NULL,
>  comment text NOT NULL
> )
SELECT * FROM connectby('wallposts', 'id', 'parentid', '<entrypoint>',
0, '~')
  AS t(keyid text, parent_keyid text, level int, branch text);

HTH,

Johan Nel
Durban, South Africa.

pgsql-general by date:

Previous
From: Guy Rouillier
Date:
Subject: Re: Enumerating a row set
Next
From: "Marc Mamin"
Date:
Subject: Re: Enumerating a row set