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

Delete Query Not Working (Access 2003)

Status
Not open for further replies.

dawnd3

Instructor
Jul 1, 2001
1,153
US
Hi there, what am I doing wrong? I am trying to delete the records from one table that don't match up with the records from another table (based on NationalID field)

Here is the SQL:

DELETE MemberInfo.*, MemberInfo.NationalID, tblFPAData.ID
FROM tblFPAData RIGHT JOIN MemberInfo ON tblFPAData.ID = MemberInfo.NationalID
WHERE (((MemberInfo.NationalID) Is Not Null) AND ((tblFPAData.ID) Is Null))
WITH OWNERACCESS OPTION;


Thanks!!!

Dawn

 
So you want to delete the rows from MemberInfo that don't match tblFPAData ?
You may either try this:
DELETE MemberInfo.* FROM MemberInfo LEFT JOIN tblFPAData ON MemberInfo.NationalID = tblFPAData.ID
WHERE MemberInfo.NationalID Is Not Null AND tblFPAData.ID Is Null
Or this:
DELETE FROM MemberInfo
WHERE NationalID Is Not Null
AND NationalID Not In (SELECT ID FROM tblFPAData)

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