Re: Finding rows in table A which do not have a match in table B

From: Dave Hammond <dh1760_at_gmail.com>
Date: 12 Oct 2006 13:12:06 -0700
Message-ID: <1160683926.701482.37930_at_c28g2000cwb.googlegroups.com>


On Oct 12, 3:38 pm, "David Portas"
<REMOVE_BEFORE_REPLYING_dpor..._at_acm.org> wrote:
> Dave Hammond wrote:
> > Given two tables A and B, both containing a column X with identical
> > data, I'm trying to formulate a query which will return all rows from
> > table A where there are no rows in table B with a matching value in
> > column X.
>
> Always include DDL because keys and constraints make a difference -
> that's what they are for. Here's my guess:
>
> SELECT NAME, ID, DATE
> FROM A
> WHERE NOT EXISTS
> (SELECT 1
> FROM B
> WHERE A.NAME = B.NAME
> AND A.DATE = B.DATE);
>
> --
> David Portas

David, thanks very much -- that worked perfectly!

-Dave H. Received on Thu Oct 12 2006 - 22:12:06 CEST

Original text of this message