delete duplicates

  • Thread starter Thread starter Darren
  • Start date Start date
D

Darren

I have one table (table 1) with a column A & B and another table (table 2)
with columns C & D. Now there are duplicates in table 2 on the values in
column C. I need to keep the entries where 1A=2C and 1B=2D and delete the
entries where 1A=2C and 1B does not = 2D

please help
 
So you want to keep the entries where Table1.A = Table2.B and Table1.C =
Table2.D, and delete the non-matching entries from table1?

DELETE FROM Table1
WHERE NOT EXISTS
(SELECT B FROM Table2
WHERE Table1.A = Table2.B and Table1.C = Table2.D);

If subqueries are new, here's an introduction:
http://allenbrowne.com/subquery-01.html
 
Back
Top