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

From: Gene Wirchenko <genew_at_ocis.net>
Date: Thu, 12 Oct 2006 13:09:30 -0700
Message-ID: <g58ti2hnqel0ah39bqc2ut4f5p1bsqsbfv_at_4ax.com>


"Dave Hammond" <dh1760_at_gmail.com> wrote:

>Hi All,
>
>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.

     But your proposed result does not show a row of A.

>For example, assuming the tables each contain NAME and DATE columns:
>
>Table A looks like:
>
>NAME ID DATE
>---- -- ----
>JOHN 01 2006-10-12
>JANE 02 2006-10-12
>FRED 03 2006-10-12
>
>Table B looks like:
>
>NAME HOURS DATE
>---- ----- ----
>JOHN 40 2006-10-12
>JANE 40 2006-10-12
>FRED 25 2006-09-30
>
>The rows for JOHN and JANE have identical values in the DATE field of
>both tables; however, the row for FRED has a different DATE value in
>each table, so it would appear in the query result:
>
>NAME ID DATE
>---- -- ----
>FRED 03 2006-09-30
     This is not a row of A.

>This is probably a newbie SQL question, but I can't find the solution,
>so I'm asking the experts. :)

     Please clarify what you actually want.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:

     I have preferences.
     You have biases.
     He/She has prejudices.
Received on Thu Oct 12 2006 - 22:09:30 CEST

Original text of this message