D
DZ
I have two tables. Table1 and Table2.
Both have 3 fields in common: Name, Address and Location fields.
The combined value of the Name, Address and Locations fields make each
record unique.
Table1 has duplicate values of Name, Address and Location combined.
Table2 has unique values of Name, Address and Location combined.
I want to delete all the existing records in Table2, except records in
Table2 whose combined value of the Name, Address and Location fields already
exist in Table1.
In other words, I don't want to delete any existing records in Table2 that
have duplicates in the Name, Address and Location fields in Table1. I want
those and only those existing records in Table2 to remain untouched during
the delete process.
============================
Ultimately what i'm trying to do is to update Table2 from Table1, so that
Table2 contains all the combined (Name, Address and Location) values of
Table1 (which has duplicates). I want Table2 to have no duplicates and to
have certain records remain untouched during the delete process as I stated
above.
This is how i planned to do this.
1st Step - I would do a delete first as described above (that's what I
need help with).
2nd Step - I want to send all records from Table1 to Table2 except
duplicates in the Name, Address fields. I know how to do this second step. In
Table2, I would make the Name, Address and location fields a combined primary
key, too keep duplicates from being added to Table2. Then run an Append Query
from Table1 to Table2.
The reason for the delete process that deletes all records from Table2
except dups in Table1 is that Table2 must be a subset of Table1 and never
contain records whose combined value of the Name, Address and Location
fields is not in Table1 and previous updates from Table1 may have placed
records in Table2 that should not be there, because the current data in
table1 does not contain them.
Sorry for the longwinded explanation . I hope this clear !
Thanks for any ideas for how to accomplish the delete (Step 1)
Both have 3 fields in common: Name, Address and Location fields.
The combined value of the Name, Address and Locations fields make each
record unique.
Table1 has duplicate values of Name, Address and Location combined.
Table2 has unique values of Name, Address and Location combined.
I want to delete all the existing records in Table2, except records in
Table2 whose combined value of the Name, Address and Location fields already
exist in Table1.
In other words, I don't want to delete any existing records in Table2 that
have duplicates in the Name, Address and Location fields in Table1. I want
those and only those existing records in Table2 to remain untouched during
the delete process.
============================
Ultimately what i'm trying to do is to update Table2 from Table1, so that
Table2 contains all the combined (Name, Address and Location) values of
Table1 (which has duplicates). I want Table2 to have no duplicates and to
have certain records remain untouched during the delete process as I stated
above.
This is how i planned to do this.
1st Step - I would do a delete first as described above (that's what I
need help with).
2nd Step - I want to send all records from Table1 to Table2 except
duplicates in the Name, Address fields. I know how to do this second step. In
Table2, I would make the Name, Address and location fields a combined primary
key, too keep duplicates from being added to Table2. Then run an Append Query
from Table1 to Table2.
The reason for the delete process that deletes all records from Table2
except dups in Table1 is that Table2 must be a subset of Table1 and never
contain records whose combined value of the Name, Address and Location
fields is not in Table1 and previous updates from Table1 may have placed
records in Table2 that should not be there, because the current data in
table1 does not contain them.
Sorry for the longwinded explanation . I hope this clear !
Thanks for any ideas for how to accomplish the delete (Step 1)