duplicate-removal

MySQL cleanup table from duplicated entries AND relink FK in depending table

浪子不回头ぞ 提交于 2019-12-20 04:58:07
问题 Here is my situation: I have 2 tables, patient and study . Each table has its own PK using autoincrement. In my case, the pat_id should be unique. It's not declared as unique at database level since it could be non unique is some uses (it's not a home made system). I found out how to configure the system to consider the pat_id as unique, but I need now to cleanup the database for duplicated patients AND relink duplicated patients in study table to remaining unique patient , before deleting

SQL Query Duplicate Removal Help

孤街浪徒 提交于 2019-12-20 04:12:56
问题 I need to remove semi duplicate records from the following table ID PID SCORE 1 1 50 2 33 20 3 1 90 4 5 55 5 7 11 6 22 34 For any duplicate PID's that exist I want to remove the lowest scoring record. In the example above ID 1 would be remove. I'm trying to come up with a way of doing this without using loops but am really struggling. Any help would be appreciated. Thanks 回答1: DELETE t.* FROM Table1 t JOIN (SELECT pid, MIN(score) minScore, MAX(id) maxId FROM Table1 GROUP BY pid) t1 ON t.pid =

SQL Query Duplicate Removal Help

人走茶凉 提交于 2019-12-20 04:12:09
问题 I need to remove semi duplicate records from the following table ID PID SCORE 1 1 50 2 33 20 3 1 90 4 5 55 5 7 11 6 22 34 For any duplicate PID's that exist I want to remove the lowest scoring record. In the example above ID 1 would be remove. I'm trying to come up with a way of doing this without using loops but am really struggling. Any help would be appreciated. Thanks 回答1: DELETE t.* FROM Table1 t JOIN (SELECT pid, MIN(score) minScore, MAX(id) maxId FROM Table1 GROUP BY pid) t1 ON t.pid =

Finding duplicates in a List ignoring a field

房东的猫 提交于 2019-12-20 03:37:08
问题 I've got a List of Persons and I want to find duplicate entries, consindering all fields except id . So using the equals() -method (and in consequence List.contains() ), because they take id into consideration. public class Person { private String firstname, lastname; private int age; private long id; } Modifying the equals() and hashCode() -methods to ignore the id field are not an option because other parts of the code rely on this. What's the most efficient way in Java to sort out the

Check for duplicates while populating an array

懵懂的女人 提交于 2019-12-20 03:18:17
问题 I have an array that I populate with 6 randomly generated numbers. First it generates a random number between 1 and 49 and then checks it against the numbers in the array. If it finds a duplicate it should generate a random number again and then perform the check once again. If there are no duplicates then the number is added to the array. Here's the code: public void populateArray() { for(int i = 0; i < numberLine.length; i++) { randomNumber = 1 + randomGen.nextInt(49); for(int j = 0; j < i;

Find most recent duplicates ID with MySQL

蓝咒 提交于 2019-12-19 20:00:09
问题 I use to do SELECT email, COUNT(email) AS occurences FROM wineries GROUP BY email HAVING (COUNT(email) > 1); to find duplicates based on their email. But now I'd need their ID to be able to define which one to remove exactly. The second constraint is: I want only the LAST INSERTED duplicates. So if there's 2 entries with test@test.com as an email and their IDs are respectively 40 and 12782 it would delete only the 12782 entry and keep the 40 one. Any ideas on how I could do this? I've been

How to delete completely duplicate rows

亡梦爱人 提交于 2019-12-19 17:46:40
问题 Say i have duplicate rows in my table and well my database design is of 3rd class :- Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap'); Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap'); Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap'); Insert Into tblProduct (ProductId,ProductName,Description,Category)

How to delete completely duplicate rows

有些话、适合烂在心里 提交于 2019-12-19 17:46:12
问题 Say i have duplicate rows in my table and well my database design is of 3rd class :- Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap'); Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap'); Insert Into tblProduct (ProductId,ProductName,Description,Category) Values (1,'Cinthol','cosmetic soap','soap'); Insert Into tblProduct (ProductId,ProductName,Description,Category)

How to merge columns from different sheets without duplicates?

这一生的挚爱 提交于 2019-12-19 11:55:14
问题 How can I merge two columns of data from two different sheets into one column on a third sheet without duplicates? For Example: Sheet 1 ID 1 2 3 and Sheet 2 ID 1 6 7 3 become Sheet 3 1 2 3 6 7 回答1: It's possible to do it by an extension of the usual formula for listing unique values which would be =INDEX(Sheet1!$A$2:$A$4, MATCH(0, COUNTIF($a$1:a1, Sheet1!$A$2:$A$4), 0)) for the first list and =INDEX(Sheet2!$A$2:$A$5, MATCH(0, COUNTIF($a$1:a1, Sheet2!$A$2:$A$5), 0)) for the second list In

Scheme: Remove duplicated numbers from list

不打扰是莪最后的温柔 提交于 2019-12-19 08:16:10
问题 I wrote this code to create a list from en number of arguments given (define (create-list . e) e) But I need it to remove any duplicated numbers from the list within this block itself. I have tried and searched for hours and can't find a solution without placing dozens of lines of code on other blocks. For example let's say my input is (create-list . 2 2 3 5 5 ) I need the list created to be '(2 3 5) and not '(2 2 3 5 5 )... The order of the numbers doesn't matter. 回答1: Basically, you need to