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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table-Query Relationship 2

Status
Not open for further replies.

dmears1

Technical User
Jun 18, 2003
208
US
Access noob here with a question. I need to compare records in a Table with the results of a query. In a nutshell here's what I need to happen:

Table contains master list of records. Say there are 100 records in this table. The query returns 25 records. I need a query that will compare both and return the remaining records in the table not contained in the query. Does that make sense?

In noobish SQL:

Code:
Select from TableA join QueryB
Where TableA.ID != QueryB.ID

After googling I found mention of a "theta join" that looks like what I need to do, but I can't find instructions on accomplishing this.

Any help would be greatly appreciated.

 
SELECT A.*
FROM TableA As A LEFT JOIN QueryB As B ON A.ID = B.ID
WHERE B.ID Is Null

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
One more question: I'm guessing that the key part of the query is the "WHERE B.ID Is Null" otherwise the query would return all records contained in TableA, correct?
If so, why is that?

 
why is that
Because it's a LEFT outer join.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top