From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | sammynash(at)uboot(dot)com (Sammy), pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Chain/Thread Problem |
Date: | 2003-05-16 17:22:37 |
Message-ID: | 200305161822.37391.dev@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2003-05-16 17:29:09 | Re: Efficiency Issue with "SELECT IN (..)" and "SELECT .. OR .." |
Previous Message | J Sensel | 2003-05-16 16:53:08 | Re: Chain/Thread Problem |