pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: dave_h4@yahoo.com
To: pgsql-sql@postgresql.org
Subject: Left Join 3 tables
Date: 14 May 2003 10:35:19 -0700
Message-ID: <27ad91d2.0305140935.4fdec226@posting.google.com> (raw)

Hi Group - 

1) I have 3 tables: A, B and C
2) Each table has an unqiue associative field called cust_id
3) The cust_id HAS to be in table A, the cust_id *could* be in table
B, and the cust_id *could* be in table C
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
  b) display all emails where cust_id is in table A but *not* in table
B AND *not* in table C

Here's some of my queries of what I have:

This one is close I think:

select distinct A.email from A
left join A as ics on ics.custid = A.custid
left join B on B.custid = A.custid
left join C on C.custid  = A.custid
where ics.custid <> A.custid;

THANK YOU!

dave



view thread (2+ messages)  latest in thread

Message-ID: <27ad91d2.0305140935.4fdec226@posting.google.com>
Permalink:  ../27ad91d2.0305140935.4fdec226@posting.google.com/
Also on:    postgresql.org/message-id/27ad91d2.0305140935.4fdec226@posting.google.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: dave_h4@yahoo.com
  Subject: Re: Left Join 3 tables
  In-Reply-To: <27ad91d2.0305140935.4fdec226@posting.google.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