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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:25:02+00:00 2026-05-27T08:25:02+00:00

So I screwed up and filled a table with duplicate rows… I have a

  • 0

So I screwed up and filled a table with duplicate rows… I have a table something like this (actually THOUSANDS of somethings like this 🙁 ) :

id    gname     pname    value 
1     15         13       test 
2     15         13       test 
3     15         13       test
4     18         18       test
5     18         18       test 
6     18         18       test

This table is only supposed to allow one row of the same gname, pname and value.

So now I need to write some sql that will group all these common rows together and delete them all except ONE! Argh!

Can anyone help me, STEP ONE, I believe is just to get a statement to return all the groups of duplicates.

** BTW – I know this is totally jacked. This is a very old system that I inherited and a big client this is using this… so I’m aware of the issues. I can fix the code that caused this ONCE I get the db back to the way its supposed to be.

Thanks!

  • 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-27T08:25:03+00:00Added an answer on May 27, 2026 at 8:25 am

    If id is unique and auto-incrementing this is easy:

    DELETE Table
    WHERE ID NOT IN (SELECT MIN(id)
                      FROM Table
                      GROUP BY gname, pname, value)
    

    Do a SELECT first, though.

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

Sidebar

Related Questions

I have something like this: class Vehicle def self.set_color(input) if %w{blue red green}.include?(input) input
Consider this page @ http://www.bloodbone.ws/screwed.html I need to be able to have the a.grow
I have a grid of images, like a 2D tile set. This method is
I have a question about a method to break something apart. I get this
I have an array filled with image links and I'd like to write a
I think i screwed up something in my code,it throws this exception all the
I am trying to achieve something like this with CSS: I'd like to keep
I screwed up my last post. Lets see if I can get this one
I have built a site in wordpress and the home page is really screwed
First, I have to admit I screwed up a little with CVS. I had

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.