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

  • Thread starter Thread starter KCFlorist
  • Start date Start date
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.
 
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
 

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

Back
Top