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

How do I structure my query in this situation? 2

Status
Not open for further replies.

VBAjedi

Programmer
Dec 12, 2002
1,197
KH
I have an "Employees" table with a "SeatingZone" field where we record which of thousands of cubicle zones they sit in. Regular "snapshot" copies of this table are made for backup and historical purposes.

I need to write a query which will compare the "Employees" table to one of it's backup copies and list all employees that joined or left a seating zone. So the query would be scanning both tables for a subset of records (all employees sitting in a given zone) then listing all rows that aren't shared between the two table's subsets.

Sounds to me like it may involve a nested query but I don't know how to go about it!

VBAjedi [swords]
 
listing all rows that aren't shared between the two table's
As a starting point I'd look at the SQL code generated by the unmatched query wizard.
Furthermore I'd look at UNION QUERY

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV also once upon a time provided this very helpful answer to a similiar problem:

Code:
SELECT Table1.yourField AS Item, 'Table1 only' AS Location
FROM Table1 LEFT JOIN Table2 ON Table1.yourField=Table2.yourField WHERE Table2.yourField Is Null
UNION 
SELECT Table2.yourField, 'Table2 only'
FROM Table1 RIGHT JOIN Table2 ON Table1.yourField=Table2.yourField
WHERE Table1.yourField Is Null
 
I tried the unmatched query wizard before I posted but it didn't give me much insight... guess I'm just dense. :)

However, the example BigRed reposted helped me see it in my head... I think I can get it from here!

Thanks!



VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top