How do i compare...?

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

Guest

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?
 
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);
 
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);
 
Back
Top