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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:54:03+00:00 2026-06-06T13:54:03+00:00

Due to a bug in my javascript click handling, multiple Location objects are posted

  • 0

Due to a bug in my javascript click handling, multiple Location objects are posted to a JSON array that is sent to the server. I think I know how to fix that bug, but I’d also like to implement a server side database duplicate erase function. However, I’m not sure how to write this query.

The only affected table is laid out as

+----+------------+--------+
| ID | locationID | linkID |
+----+------------+--------+
| 64 |         13 |     14 |
| 65 |         14 |     13 |
| 66 |         14 |     15 |
| 67 |         15 |     14 |
| 68 |         15 |     16 |
| 69 |         16 |     17 |
| 70 |         16 |     14 |
| 71 |         17 |     16 |
| 72 |         17 |     16 |
| 73 |         17 |     16 |
| 74 |         17 |     16 |
| 75 |         17 |     16 |
| 76 |         17 |     16 |
| 77 |         17 |     16 |
+----+------------+--------+

As you can see, I have multiple pairs of (17, 16), while 14 has two pairs of (14, 13) and (14, 15). How can I delete all but one record of any duplicate entries?

  • 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-06T13:54:05+00:00Added an answer on June 6, 2026 at 1:54 pm

    Don’t implement post factum correction logic, put a unique index on the fields that need to be unique, that way the database will stop dupe inserts before it’s too late.

    If you’re using MySQL 5.1 or higher you can remove dupes and create a unique index in 1 command:

    ALTER IGNORE TABLE 'YOURTABLE' 
    ADD UNIQUE INDEX somefancynamefortheindex (locationID, linkID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is an example program that has a bug due to _ReadBarrier() not being
Due to a bug in my PHP script, I have created multiple erroneous entries
I have a C++ program that crashed due to a bug. It would not
I am experiencing a javascript bug in internet explorer and I suspect its due
Due to a bug that was fixed in C# 4, the following program prints
It was a bug that I just found! Hooray. The bug was due to
Recently I hit a bug due to data quality with browser support, and I
Due to a bug in Flash, I have to use the ASPXAuth cookie to
I've lost some time with a bug in my app due to user authentication.
Due to a number of constraints that I won't get into, I have to

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.