Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excluding data from one query using another query

Status
Not open for further replies.

sirace

MIS
Dec 8, 2003
34
US
Hello everyone,

Here's my dilemma. I have two queries, "mailing_list_full" and "officer_search". The fields in "mailing_list_full" include account_no, address1, address2, address3. The fields in officer_search include account_no, address1, address2, address3. These two queries' data comes from the same table, only one (mailing_list_full) has 26120 records and the officer_search query only has 168 records. I want to create a 3rd query that shows all mailing addresses minus the accounts in the officer search. So far when I try and run this query, I get no results in my output. Here's my SQL:

Code:
SELECT mailing_list_full.*
FROM mailing_list_full LEFT JOIN officer_search ON mailing_list_full.account_no = officer_search.account_no
WHERE (((mailing_list_full.account_no)<>[officer_search]![account_no]));

Anyone have suggestions?
 
You should be able to create this with the &quot;Find Unmatched Query Wizard&quot;

The sql looks like this

SELECT *
FROM [mailing_list_full] LEFT JOIN officer_search ON [mailing_list_full].[account_no] = [officer_search].[account_no]
WHERE ([officer_search].[account_no] Is Null);

Paul
 
Thanks alot for the speedy response! It worked beautifully, though I can't say I totally understand why. The concept makes sense (and obviously works) but some part of me is saying nothing should have been null... Oh well, won't tax my brain. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top