?
Solved

How do I delete unmatched records between two tables

Posted on 2008-10-08
1
Medium Priority
?
677 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

650 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