From: David W Noon <dwnoon@spamtrap.ntlworld.com>
To: pgsql-sql@postgresql.org
Subject: Re: Left Join 3 tables
Date: Thu, 15 May 2003 12:39:38 +0100
Message-ID: <rsacp-4oi.ln1@my-pc.ntlworld.com> (raw)
References: <27ad91d2.0305140935.4fdec226@posting.google.com>
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.
======================================================
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: dwnoon@spamtrap.ntlworld.com
Subject: Re: Left Join 3 tables
In-Reply-To: <rsacp-4oi.ln1@my-pc.ntlworld.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