Question : Deleting Unmatched Records MS Acess 2000

Table A

Number  Name
1            Peter
2            Paul
3            Mary
4            John
6            George
8            Oscar

Table B

Order     Town
1            Miami
2            Sydney
3            New York
4            Perth
5            Brisbane
6            Seattle
7            Tokyo
8            Canberra

Table A is missing information for 5 and 7

Table B no longer needs information for 5 and 7

I have a database problem and the only way to fix the problem and create a relationship (which is not corrupted) where the records can cascade and been deleted etc is to modify table B so that only the numbers that occur in table A are also present in table B (that is, delete the records 5 and 7 from table B)

thanks in advance,
regards
Kempvet

Answer : Deleting Unmatched Records MS Acess 2000

It should be

Currentdb.Execute "DELETE * FROM TableB WHERE Order NOT IN (SELECT Number FROM TableA)"

It means
DELETE * FROM TableB >> Delete records from tableB
WHERE Order NOT IN  >> where tableB.Order is not in the list of
(SELECT Number FROM TableA) >> numbers that exist in table A
Random Solutions  
 
programming4us programming4us