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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:43:00+00:00 2026-06-09T10:43:00+00:00

sorry, I realize my title is confusing. Please let me explain. I have a

  • 0

sorry, I realize my title is confusing. Please let me explain.

I have a database that looks like this:

| i | a | b |
| 1 | 5 | 8 |
| 2 | 3 | 3 |
| 3 | 3 | 6 |
| 4 | 5 | 8 |
| 5 | 1 | 1 |
| 6 | 3 | 3 |

Where i is the ID and a and b are two other fields. As you can see above, ID 2 and ID 6 both have a = 3 and b = 3. The same is true of ID 1 and ID 4, both having 5 for a and 8 for b. Even though the ID number is different, I still consider these rows to be duplicates and would like for all but one to be deleted. It doesn’t matter which one, and the ID numbers to not have to change to compensate for the gaps (but I’m not opposed to that).

I would be happy with a query that gets the above example to something like this:

| i | a | b |          | i | a | b |
| 3 | 3 | 6 |          | 1 | 5 | 8 |
| 4 | 5 | 8 |    or    | 2 | 3 | 3 |
| 5 | 1 | 1 |          | 3 | 3 | 6 |
| 6 | 3 | 3 |          | 5 | 1 | 1 |

Don’t hesitate to ask for more details and thanks in advance!

  • 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-09T10:43:02+00:00Added an answer on June 9, 2026 at 10:43 am
    delete from your_table
    where i not in 
    (
        select * from 
        (
          select min(i)
          from your_table
          group by a, b 
        ) x
    )
    

    MySQL can’t delete from a table that it is selecting from. That is why I made a subquery of the select with select * from () x

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

Sidebar

Related Questions

I realize this question (or questions that look like this) have been asked over
I'm really sorry, I realize there have been several questions asked about cocos2d touch
I'm working with c# and nhibernate to access the database. I have two or
i have a db like below: (sorry i couldn't upload the diagram) group table:
Sorry for the brief title, I wasn't sure how to word this. Basically I
I realize that this question is not unlike asking someone for the name of
I realize there's already been several questions like this, but I think my case
Sorry if this is a stupid question, but it's something that I'm curious about.
I realize that similar questions have been asked before. My list is displayed using
Sorry about the title. I do realize it's not very descriptive. :| Here is

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.