3
Answers

delete duplicate records in two tables ?

Photo of chamu reddy

chamu reddy

7y
168
1
delete duplicate records in two tables ? how many ways to delete duplicate records ? examples 

Answers (3)

0
Photo of Bharathi Raja
NA 400 6k 7y
  1. DELETE dupes  
  2. FROM MyTable dupes, MyTable fullTable  
  3. WHERE dupes.dupField = fullTable.dupField   
  4. AND dupes.secondDupField = fullTable.secondDupField   
  5. AND dupes.uniqueField > fullTable.uniqueField  
  1. DELETE FROM MyTable  
  2. LEFT OUTER JOIN (  
  3.    SELECT MIN(RowId) as RowId, Col1, Col2, Col3   
  4.    FROM MyTable   
  5.    GROUP BY Col1, Col2, Col3  
  6. as KeepRows ON  
  7.    MyTable.RowId = KeepRows.RowId  
  8. WHERE  
  9.    KeepRows.RowId IS NULL  


 
0
Photo of Rajkiran Swain
NA 33.9k 373.6k 7y
  1. DELETE a  
  2. FROM a  -- first table  
  3. INNER JOIN b -- second table  
  4.       ON b.ID = a.ID  
  5.       AND b.Name = a.Name  
  6.       AND b.Foo = a.Foo  
  1. delete * from table1 intersect select * from table2  
0
Photo of Ramesh Palanivel
NA 9.5k 138.7k 7y
You can compare both tables and you can delete