How can I delete non matching rows from a table? I have two tables that have a majority of related records. Table A must exist in table B. If table B record does not exist in table A delete table B record.
I am hoping there is a method to do this with a query rather then coding to populate a datatable and interating through each reocrd to see if there is a match.
TableA
keyID, foreignID, text
TableB
keyID, recordID, text
foriegnID and recordID are the related fields. I did not design these tables.
Somethins like this....
DELETE * FROM TableB WHERE (SELECT [foreignID] FROM TableA) <> recordID;
UPDATE: I can retireve the records needing to be deleted with query, but I would like to just delete them.
SELECT * FROM TableA LEFT JOIN TableB ON TableA.[foreignID] = TableB.[recordID] WHERE (((TableB.recordID) Is Null));
I am using vb.net to process a series of Access database.