Exclude record if meet criteria

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
 
V

Van T. Dinh

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top