Exclude record if meet criteria

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am writing a select querry based on 2 tables.
I want to exclude each record in table A from the output whenever the
"FirstName" field in Table A matches the "FirstName" Field in Table B.
For criterion, I specied:
"Not Like [TableB]![FrstName]",
OR simply "NOT [TableB]![FrstName]".
My intent is to remove all records for which the FirstName field match
across the tables.
Instead, I got some weired results.
The querry produced more records than there are records in Table A.
What did I do wrong?
Thanks.
David
 
It sounds to me that you need a Left Join. Something like:

SELECT A.*
FROM A
LEFT JOIN B ON A.FirstName = B.FirstName
WHERE B.RecordID is Null
 
Hi Van,
That works beautifully. Thanks.
David

Van T. Dinh said:
It sounds to me that you need a Left Join. Something like:

SELECT A.*
FROM A
LEFT JOIN B ON A.FirstName = B.FirstName
WHERE B.RecordID is Null

--
HTH
Van T. Dinh
MVP (Access)




David said:
Hi,
I am writing a select querry based on 2 tables.
I want to exclude each record in table A from the output whenever the
"FirstName" field in Table A matches the "FirstName" Field in Table B.
For criterion, I specied:
"Not Like [TableB]![FrstName]",
OR simply "NOT [TableB]![FrstName]".
My intent is to remove all records for which the FirstName field match
across the tables.
Instead, I got some weired results.
The querry produced more records than there are records in Table A.
What did I do wrong?
Thanks.
David
 
Back
Top