Questions tagged [duplicates]

The "duplicates" tag concerns detecting and/or dealing with multiple instances of items in collections.

A duplicate is any re-occurrence of an item in a collection. This can be as simple as two identical strings in a list of strings, or multiple complex objects which are treated as the same object when compared to each other.

This tag may pertain to questions about preventing, detecting, removing, or otherwise dealing with unwanted duplicates, or adapting to safely allow duplicates.

15777 questions
47
votes
5 answers

Delete all but one duplicate record

I have a table that is supposed to keep a trace of visitors to a given profile (user id to user id pair). It turns out my SQL query was a bit off and is producing multiple pairs instead of single ones as intended. With hindsight I should have…
James P.
  • 19,313
  • 27
  • 97
  • 155
47
votes
18 answers

Duplicating model instances and their related objects in Django / Algorithm for recusrively duplicating an object

I've models for Books, Chapters and Pages. They are all written by a User: from django.db import models class Book(models.Model) author = models.ForeignKey('auth.User') class Chapter(models.Model) author = models.ForeignKey('auth.User') …
jb.
  • 9,987
  • 12
  • 39
  • 38
47
votes
9 answers

How do I delete all the duplicate records in a MySQL table without temp tables

I've seen a number of variations on this but nothing quite matches what I'm trying to accomplish. I have a table, TableA, which contain the answers given by users to configurable questionnaires. The columns are member_id, quiz_num, question_num,…
MivaScott
  • 1,763
  • 1
  • 12
  • 30
46
votes
8 answers

JQuery: Remove duplicate elements?

Say I have a list of links with duplicate values as below: Book Magazine Book Book DVD DVD DVD Book How would I, using…
Keith Donegan
  • 26,213
  • 34
  • 94
  • 129
45
votes
9 answers

Duplicate Package - update / upgrade - Centos

When I try running yum update on a CentOS 6.3 box, I am getting errors, and says to run yum check. The output of yum check is: ➜ ~ yum check Loaded plugins: fastestmirror glibc-2.12-1.107.el6_4.5.x86_64 is a duplicate with…
Justin
  • 42,716
  • 77
  • 201
  • 296
45
votes
7 answers

Fast ways to avoid duplicates in a List<> in C#

My C# program generates random strings from a given pattern. These strings are stored in a list. As no duplicates are allowed I'm doing it like this: List myList = new List(); for (int i = 0; i < total; i++) { string random_string…
Robert Strauch
  • 12,055
  • 24
  • 120
  • 192
43
votes
11 answers

Removing Duplicates From Dictionary

I have the following Python 2.7 dictionary data structure (I do not control source data - comes from another system as is): {112762853378: {'dst': ['10.121.4.136'], 'src': ['1.2.3.4'], 'alias': ['www.example.com'] }, 112762853385:…
Bit Bucket
  • 942
  • 4
  • 10
  • 13
43
votes
9 answers

How to allow duplicate keys in php array

How to allow php array to have duplicate keys? When I try to insert a key, value pair with already existing key it overwrites the value of corresponding previous key with the new value. Is there a way that I could maintain both duplicate keys having…
sudh
  • 1,085
  • 4
  • 12
  • 13
43
votes
5 answers

Fastest "Get Duplicates" SQL script

What is an example of a fast SQL to get duplicates in datasets with hundreds of thousands of records. I typically use something like: SELECT afield1, afield2 FROM afile a WHERE 1 < (SELECT count(afield1) FROM afile b WHERE a.afield1 =…
Johan Bresler
  • 6,450
  • 11
  • 56
  • 77
42
votes
9 answers

Prevent auto increment on MySQL duplicate insert

Using MySQL 5.1.49, I'm trying to implement a tagging system the problem I have is with a table with two columns: id(autoincrement), tag(unique varchar) (InnoDB) When using query, INSERT IGNORE INTO tablename SET tag="whatever", the auto increment…
robert
  • 1,523
  • 5
  • 19
  • 27
42
votes
6 answers

How to drop columns which have same values in all rows via pandas or spark dataframe?

Suppose I've data similar to following: index id name value value2 value3 data1 val5 0 345 name1 1 99 23 3 66 1 12 name2 1 99 23 2 66 5 2 name6 1 99 23 7 …
CYAN CEVI
  • 813
  • 1
  • 9
  • 19
42
votes
5 answers

Removing duplicate rows (based on values from multiple columns) from SQL table

I have following SQL table: AR_Customer_ShipTo +--------------+------------+-------------------+------------+ | ARDivisionNo | CustomerNo | CustomerName | ShipToCode | +--------------+------------+-------------------+------------+ | …
Vikram
  • 3,996
  • 8
  • 37
  • 58
42
votes
6 answers

Android Studio: Duplicate files copied in APK META-INF/DEPENDENCIES when compile

I exported my project from Eclipse and imported to Android Studio using the instructions in this link: http://developer.android.com/sdk/installing/migrate.html When I build, I have an error: Duplicate files copied in APK META-INF/DEPENDENCIES After…
TrungNVT
  • 671
  • 2
  • 6
  • 8
42
votes
4 answers

jQuery Duplicate Selector error

I am currently trying to set up a table with 6 clickable cels that allow for a input box to appear so you can add comments but I am getting a duplicated jQuery selector error and also through debugging my second function I found that .html() is not…
thehoule64
  • 1,761
  • 5
  • 15
  • 22
41
votes
17 answers

How can I remove duplicate words in a string with Python?

Following example: string1 = "calvin klein design dress calvin klein" How can I remove the second two duplicates "calvin" and "klein"? The result should look like string2 = "calvin klein design dress" only the second duplicates should be removed…
burner007
  • 643
  • 3
  • 10
  • 23