delete duplicate records in two tables ?
delete duplicate records in two tables ? how many ways to delete duplicate records ? examples
Answers (3)
0
- DELETE dupes
- FROM MyTable dupes, MyTable fullTable
- WHERE dupes.dupField = fullTable.dupField
- AND dupes.secondDupField = fullTable.secondDupField
- AND dupes.uniqueField > fullTable.uniqueField
- DELETE FROM MyTable
- LEFT OUTER JOIN (
- SELECT MIN(RowId) as RowId, Col1, Col2, Col3
- FROM MyTable
- GROUP BY Col1, Col2, Col3
- ) as KeepRows ON
- MyTable.RowId = KeepRows.RowId
- WHERE
- KeepRows.RowId IS NULL
0
- DELETE a
- FROM a -- first table
- INNER JOIN b -- second table
- ON b.ID = a.ID
- AND b.Name = a.Name
- AND b.Foo = a.Foo
- delete * from table1 intersect select * from table2
0
You can compare both tables and you can delete