Deleting matching records from another table

DaveJHPT

Registered User.
Local time
Today, 06:08
Joined
Mar 17, 2005
Messages
64
Hi

Apologies if there is a previous post that answers this - I've looked, but can't find anything that works.

I have two tables with identical structures. tblA contains a subset of the records on tblB, with identical values on all fields except ID. I need to remove from tblB all records appearing on tblA. I thought the following would work:

DELETE tblB.* from tblB
INNER JOIN tblA ON tblB.Field1 = tblA.Field1
AND tblB.Field2 = tblA.Field2
AND tblB.Field3 = tblA.Field3...

but I get "Could not delete from specified tables".

What am I doing wrong? Or is there an easier way?

Dave
 
Delete from tblb
where tblb ID in
(Select B.ID from tblb B inner join tbla a on B.fld1 = A.fld1 AND b.fld2 = A.fld2 AND etc.)

I would run the select by itself first to verify.
 
Thanks very much. Obvious once you see it!

Dave
 

Users who are viewing this thread

Back
Top Bottom