Solved

How do I delete unmatched records between two tables

Posted on 2008-10-08
1
603 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
Comment Utility
this should do:
DELETE * FROM Table2
WHERE ID NOT IN (SELECT ID FROM TABLE1)

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Help with SQL Query 23 39
Numbers are exporting as text 5 24
Access 2010 3 15
VBA Shell can't Find Word document 11 38
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now