How do i compare...?

J

Justin

Hi,
How do i compare the records in the two different tables? And if they don't
correspond how can i delete them?

For example, the first table has "A" value, But second table not. So how can
i compare them and delete the "A" value?
 
A

Allen Browne

This example deletes all records from TableB if there's no record in the
"ID" field of TableA that matches the ID field of TableB:

DELETE FROM TableB
WHERE NOT EXISTS
(SELECT ID FROM TableA
WHERE TableA.ID = TableB.ID);
 
J

Justin

But this is not a VBA sample.



Allen Browne said:
This example deletes all records from TableB if there's no record in the
"ID" field of TableA that matches the ID field of TableB:

DELETE FROM TableB
WHERE NOT EXISTS
(SELECT ID FROM TableA
WHERE TableA.ID = TableB.ID);
 
Top