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

  • SEARCH
  • Home
  • 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 6900115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:30:21+00:00 2026-05-27T07:30:21+00:00

Duplicate of How to delete duplicate records in mysql database? id | name |

  • 0

Duplicate of How to delete duplicate records in mysql database?

   id  |  name   |      link
    1     bla     www.google.com
    2     lal     www.stackoverflow.com
    3     afs     www.google.com
    4     sds     www.microsoft.com

In my database there some rows with same link. I want to delete one of that rows with the same link.

Such as, in my example I want to delete the row with the id = 3 but I want to keep id = 1.

How can I do this?

by the way there are 5840 rows. and I don’t know which are the same. I need a code to compare them

  • 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-05-27T07:30:22+00:00Added an answer on May 27, 2026 at 7:30 am

    trick is to keep latest value with comparing ids

    DELETE FROM table_name t1, table_name t2 WHERE t1.name = t2.name and t1.link = t2.link and t1.id < t2.id
    

    It’s just and idea, this is a fully functional example on my oracle environment (I haven’t use db few weeks, so I’m trying to minimalize the query right now, sorry)

    SQL> select * from dup;
    
        ID    STH       STH2
    ---------- ---------- ----------
         1     45         45
         2     45         56
         3     45         45
         4     14         56
         5     14         56
    
    
    DELETE FROM dup where id in (SELECT DISTINCT t1.id FROM dup t1, dup t2 WHERE t1.sth = t2.sth and t1.sth2 = t2.sth2 and t1.id < t2.id);
    
    SQL> select * from dup;
    
        ID    STH       STH2
    ---------- ---------- ----------
         2     45         56
         3     45         45
         5     14         56
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to delete duplicate records in mysql database? there are duplicate rows
What's the best way to delete duplicate records in a mysql database using rails
What is the simplest way to delete records with duplicate name in a table?
I'm trying to do something with the duplicate records in a mysql database. however,
Possible Duplicate: MySQL delete row from multiple tables I have 5 tables: members member_videos
I have a mySQL db with duplicate records, as from the attached image. I
Does anyone have an elegant sql statement to delete duplicate records from a table,
I tried to delete duplicate records in my DB. The only difference is the
I have a table in my database which has duplicate records that I want
How would I delete all duplicate data from a MySQL Table? For example, with

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.