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 8264915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:37:24+00:00 2026-06-08T04:37:24+00:00

I have a table that contains some duplicate redords. I want to make records

  • 0

I have a table that contains some duplicate redords. I want to make records unique. I created a new table (say, destination) and I specified a unique column in it. How can copy records from table1 (source) such that, if the record inserted in the destination table, it does not insert it again.

  • 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-08T04:37:26+00:00Added an answer on June 8, 2026 at 4:37 am

    You can use the “select into” construct and select insert only distinct rows, like this:

    insert into table_without_dupes (column0, column1) select distinct column0, column1 from table_with_dupes
    

    If you have autoincrement or other columns that makes the rows distinct, you can just leave them out of the insert and select parts of the statement.

    Edit:

    If you want to detect duplicates by a single column, you can use group by:

    insert into table_without_dupes (column0, column1) select column0, column1 from table_with_dupes group by column0
    

    MySQL will allow you to refer non-aggregated columns in select, but remember that the documentation says “The server is free to choose any value from each group”, if you want to select one specific row of the groups, you might find this example useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that contains some blob fields that I don't want to
I want to have a form that contains a table of fields and some
Say that I have a table with a bunch of records, which I want
I have a database table that contains some records to be processed. The table
I have an HTML table that contains some 500 rows. I have an input
I have a jsp that contains a table with some information from db. I
I have a table that contains some user data: user_id | guest_id | time_seen
I have a MySQL table called items that contains thousands of records. Each record
I have a table that contains some statistic data which is collected per hour.
I have a large table (~10 million records) that contains several keys into other,

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.