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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top