Deleting records from an "Unmatched" query

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

Guest

Hoping someone can help me resolve a seamingly simple task. I have a query
that finds records in Table1 that do not have matching fields in Table2 and
then I want to delete those records from Table1. I'm obviously a novice but,
I usually get by. Need help this time. Thanks. (btw, running Access 2000 &
2007)
 
SImplest is one field in A matches to one field in B

DELETE *
FROM TableA
WHERE TableA.SomeField IN
(SELECT MatchingField FROM TableB)

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Thank you for your response John. I'm almost there. What I actually need is
the inverse of this. I want to delete all records in TableA which has a
particular field that does not match the same field name in TableB. Is this
possible? Thanks again.
 
Simplest would be the following

DELETE *
FROM TableA
WHERE TableA.SomeField NOT IN
(SELECT MatchingField FROM TableB)


Simplest does not mean most efficient.


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Back
Top