X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C799E47694F for ; Fri, 16 May 2003 10:47:11 -0400 (EDT) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with ESMTP id 64065-01 for ; Fri, 16 May 2003 10:47:10 -0400 (EDT) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 4DEE8476344 for ; Fri, 16 May 2003 10:47:10 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id 27FFB43A611; Fri, 16 May 2003 10:47:10 -0400 (EDT) From: sammynash@uboot.com (Sammy) X-Newsgroups: comp.databases.postgresql.sql Subject: Chain/Thread Problem Date: 16 May 2003 07:46:43 -0700 Organization: http://groups.google.com/ Lines: 20 Message-ID: <6729af8d.0305160646.d9ab2d2@posting.google.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/349 X-Sequence-Number: 13514 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) ie a sucessulf qurey would return rows 1,2 & n because they are all in the chain. Hope you can help me with my problem,