Solved

How do I delete unmatched records between two tables

Posted on 2008-10-08
1
632 Views
Last Modified: 2013-11-27
I have two tables, table1 and table 2.  Table 2 has some records that are not in Table 1. I need to delete those records from table 1 so both tables contain only same records. in the example deleting records 2 and 4 from Table2. I have close to 100K records, hence diut it manuuly is out of a question.

TABLE1.ID             TABLE2.ID
1                             1
3                             2
5                             3
                               4
                               5

0
Comment
Question by:RalphyC
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 22669608
this should do:
DELETE * FROM Table2
WHERE ID NOT IN (SELECT ID FROM TABLE1)

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question