pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: sammynash@uboot.com
To: pgsql-sql@postgresql.org
Subject: Re: Chain/Thread Problem
Date: Fri, 16 May 2003 18:22:37 +0100
Message-ID: <200305161822.37391.dev@archonet.com> (raw)
In-Reply-To: <6729af8d.0305160646.d9ab2d2@posting.google.com>
References: <6729af8d.0305160646.d9ab2d2@posting.google.com>

On Friday 16 May 2003 3:46 pm, Sammy wrote:
> Hi,
>
> I have a SQL problem for you all. What SQL qurey would I have to make
> on the following table to extract the chain (thread) of emails in a
> conversation.
>
>
>          id|emailid|referenceid
>          -----------------------
>           1|  e125 |   Null             (Start of chain)
>           2|  r1fe |   e125             (2nd letter in chain)
>           ...
>           ...
>           n|  e4ju |   r1fe             (3rd in chain)

Search the archives for "connect by", "hierarchy", "nested" and "celko" - this 
is a limitation of SQL. In your particular case, I'd add a SERIAL "thread_id" 
column which is autogenerated for the first msg in a thread and set to the 
first message for all others.

You might want to check the contrib/ directory, I've got a feeling there's an 
example table-function to do something like this.
-- 
  Richard Huxton



view thread (3+ messages)

Message-ID: <200305161822.37391.dev@archonet.com>
Permalink:  ../200305161822.37391.dev@archonet.com/
Also on:    postgresql.org/message-id/200305161822.37391.dev@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, sammynash@uboot.com
  Subject: Re: Chain/Thread Problem
  In-Reply-To: <200305161822.37391.dev@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox