How do I delete the contents of 1 table using what is in another t

K

KCFlorist

I have a table called ALL CONTACTS and another called TO REMOVE. I need to
run some kind of query that will remove the data in my ALL CONTACTS based
upon the info that is in the TO REMOVE but haven't figured it out yet. My
ALL CONTACTS are my customers who I want to email; the TO REMOVE are the ones
I have already sent an email to so I obviously want to remove them from my
ALL CONTACTS so I do not end up emailing them again. Any help would be
appreciated.
 
M

Michel Walsh

To permanently remove them (well, until you append them again)?

Make a backup, just in case, before trying on real data.


DELETE DISTINCTROW all_contacts.*
FROM all_contacts INNER JOIN to_remove
ON all_contacts.id = to_remove.id


or


DELETE all_contacts.*
FROM all_contacts
WHERE all_contacts.id IN( SELECT to_remove.id FROM to_remove)



Vanderghast, Access MVP
 
Top