Delete Query Question

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

Guest

I have a table that I created with a make table query that displays records that match on all fields between two different tables. What I need to do now is remove the records that match from both of those tables. I thought I could use the records from the table I created to remove those records, but perhaps I can’t. I am not an experienced Access programmer, but I have worked with it for awhile now and I don’t see a way to do this. Am I approaching the problem incorrectly or is there a way to have Access do this?
 
You need to use a subquery in this situation. A delete query cannot have
joined tables if you're just wanting to delete from one table.

Try a query similar to this:

DELETE TableNameA.* FROM TableNameA
WHERE EXISTS
(SELECT TableNameB .* FROM TableNameB
WHERE TableNameA.PrimaryKeyField=TableNameB.PrimaryKeyField);



Alternatively,

DELETE TableNameA.* FROM TableNameA
WHERE TableNameA.PrimaryKeyField IN
(SELECT TableNameB.PrimaryKeyField FROM TableNameB);


--
Ken Snell
<MS ACCESS MVP>

Patrick Brazelle said:
I have a table that I created with a make table query that displays
records that match on all fields between two different tables. What I need
to do now is remove the records that match from both of those tables. I
thought I could use the records from the table I created to remove those
records, but perhaps I can't. I am not an experienced Access programmer, but
I have worked with it for awhile now and I don't see a way to do this. Am I
approaching the problem incorrectly or is there a way to have Access do
this?
 
Back
Top