Delete duplicate records from MySQL Database

Submitted by:Andery Smith

Date added:05 September, 2013

Category:MySQL

Use the same table to query against itself. The greater then sign does the main job of returning only one records of both duplicate records.

Tags: delete duplicate , delete records

Code Snippet:

    DELETE FROM table1
USING table1, table1 AS vtable
WHERE (
table1.ID > vtable.ID
)
AND (
table1.field1 = vtable.field1
)
AND (
table1.field2 = vtable.field2
)
AND (
table1.field3 = vtable.field3
)
AND (
table1.field4 = vtable.field4
)
 
 

Comments