Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8635293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:56:21+00:00 2026-06-12T09:56:21+00:00

I am trying to delete duplicate records from a mysql database. With the below

  • 0

I am trying to delete duplicate records from a mysql database. With the below command, it will delete all duplicates and will keep one row. In my database there are 300,000 records and I expect some 100,000 rows are duplicates.

The duplicates need to be deleted by the below command but the problem is, I had given the command in the evening after 9 hours it is still running.

 DELETE n1 FROM tableA n1,tableA n2 WHERE n1.title= n2.title AND n1.id > n2.id

What is happening? Can anyone explain?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:56:23+00:00Added an answer on June 12, 2026 at 9:56 am

    Trying:

    select * from tableA as n1 join tableA as n2 on n1.title = n2.title AND n1.id > n2.id;
    

    And to explain it: n1.title = n2.title does not use an index.

    This query will be better:

    delete from `t2` where `id` in (
        select cid from (
           select max(id) as cid from t2 group by title having count(*) > 1
        ) as c
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do something with the duplicate records in a mysql database. however,
I'm trying to make sql who will delete all duplicate titles BUT must delete
I am trying to delete MySQL table rows from a Web page using Perl.
I am trying to remove duplicate data from my database. I found a nice
I'm trying to delete all the duplicate points within two array lists. Each list
I am trying to write some SQL to automatically delete some records from the
Possible Duplicate: outputting values from database into html table PHP I am trying to
I'm trying to delete a specific line by id from a file in C++
I'm trying to delete certain lines from a file. My file is a .txt
I'm trying to delete all rows in a table using Castle ActiveRecord. Normally, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.