top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to delete duplicate records in MySQL or SQL?

+1 vote
How to delete duplicate records in MySQL or SQL?
posted Sep 5, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Following query first selects the duplicate rows and creates a temporary table temp and the deletes the duplicate rows.

DELETE FROM table_name  
where column_name in(
    SELECT  column_name 
        FROM (
                select column_name 
                FROM table_name
                GROUP BY column_A, column_B, column_C, ... 
                having COUNT(*)>1)temp
answer Sep 5, 2014 by Amit Kumar Pandey
Similar Questions
0 votes

I wish to delete records in my database that is older than 3 months.

$todays_date = date('Y-m-d');
$old_records_to_delete = ???

$sql = "DELETE FROM table WHERE date >= '$old_records_to_delete'";
mysql_query($sql, $connect_db) or die(mysql_error());

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.