X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C8E8147668A for ; Thu, 15 May 2003 07:40:36 -0400 (EDT) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with ESMTP id 62300-09 for ; Thu, 15 May 2003 07:40:30 -0400 (EDT) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 525B1475458 for ; Thu, 15 May 2003 07:40:30 -0400 (EDT) Received: by news.hub.org (Postfix, from userid 8) id 34FDB43A611; Thu, 15 May 2003 07:40:30 -0400 (EDT) Message-Id: From: David W Noon Subject: Re: Left Join 3 tables X-Newsgroups: comp.databases.postgresql.sql References: <27ad91d2.0305140935.4fdec226@posting.google.com> Lines: 27 User-Agent: KNode/0.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Date: Thu, 15 May 2003 12:39:38 +0100 X-Complaints-To: abuse@ntlworld.com Organization: ntl Cablemodem News Service To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/323 X-Sequence-Number: 13488 On Wednesday 14 May 2003 18:35 in <27ad91d2.0305140935.4fdec226@posting.google.com>, Hunter (dave_h4@yahoo.com) wrote: > 4) I need my query to: > a) count all rows where cust_id is in table A but *not* in table B > AND *not* in table C SELECT COUNT(*) FROM A WHERE NOT EXISTS(SELECT 1 FROM B WHERE B.cust_id = A.cust_id) AND NOT EXISTS(SELECT 1 FROM C WHERE C.cust_id = A.cust_id); > b) display all emails where cust_id is in table A but *not* in table > B AND *not* in table C SELECT A.email FROM A WHERE NOT EXISTS(SELECT 1 FROM B WHERE B.cust_id = A.cust_id) AND NOT EXISTS(SELECT 1 FROM C WHERE C.cust_id = A.cust_id); -- Regards, Dave ====================================================== dwnoon@spamtrap.ntlworld.com (David W Noon) Remove spam trap to reply via e-mail. ======================================================