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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:41:07+00:00 2026-05-31T19:41:07+00:00

I have a table with a few thousand rows. The table contains two columns,

  • 0

I have a table with a few thousand rows. The table contains two columns, name and email. I have several duplicate rows, for example:

  • John Smith | john@smith.com
  • John Smith | john@smith.com
  • Erica Smith | erica@smith.com
  • Erica Smith | erica@smith.com

What would be the easiest way to delete all duplicate results. For example, such that the table’s content would = SELECT name, DISTINCT(email) FROM table.

  • 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-31T19:41:08+00:00Added an answer on May 31, 2026 at 7:41 pm

    You could pretty easily do this by selecting that query into another table, then renaming it to replace the original.

    CREATE TABLE `table2` (
      `name` varchar(255), 
      `email` varchar(255), 
      UNIQUE KEY `email` (`email`));
    INSERT INTO `table2` SELECT `name`, DISTINCT(`email`) FROM `table`;
    RENAME TABLE `table` TO `table1`;
    RENAME TABLE `table2` TO `table`;
    

    Note that this CREATE should be adjusted to your actual table format. I added the unique key on the email field as a suggestion on how you would prevent duplicates in the first place.

    Alternatively, you could loop over this

    DELETE FROM `table` 
    WHERE `email` IN (
      SELECT `email` FROM `table` GROUP BY `email` HAVING count(*) > 1
    ) LIMIT 1
    

    Which would delete one duplicate record per call. The importance of the limit is to not remove both rows for any duplicate

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

Sidebar

Related Questions

I have a jqgrid where the database table has a few thousand rows, but
I have a page with a table on it that has several thousand rows
I have a table called downloads with a few thousand rows. I just added
I have the following problem. I have a table with a few hundred thousand
I have a table with few columns and one of the column is DockNumber.
I have a table with a few rows of data. I would like to
I have a table, tblDocs that has a few columns: DocName varchar(50) DocLocation int
I have a query in VBA that Adds a few columns to a table.
So I have a database with a few tables. The first table contains the
I have a database table with a few thousand entries. A part of the

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.