Problem with Delete Query

  • Thread starter Thread starter Paul Ridings
  • Start date Start date
P

Paul Ridings

Hi

I'm trying to delete some records from my table (tblDefendant) where the
DefID in that table exists in a temp table I have populated with some
DefID's. The query I have is below :-

DELETE tblDefendant.* FROM tblDefendant INNER JOIN tblTempTable ON
tblDefendant.DefID = tblTempTable.DefID

I have also tried :-
DELETE tblDefendant.*, tblDefendant.DefId FROM tblDefendant, tblTempTable
WHERE (((tblDefendant.DefId)=[tblTempTable].[DefID]));

When I run the first one, I'm getting 'Could'nt delete from the specified
tables'. I could run a separate delete query for each Defendant Record, but
I thought that would be a bit impractical.

Any help would be greatly appreciated.

Thanks

Paul
 
Try (untested):

DELETE tblDefendant.*
FROM tblDefendant
WHERE tblDefendant.DefID In
( SELECT tblTempTable.DefID
FROM tblTempTable )
 
Back
Top