mardi 16 janvier 2018

Use mysql group by or Java comparator o find duplicates from table

My task is to fetch duplicates from a table. Simple solution to this problem would be using group by clause. But my scenario is a little different :

Structure of myTable

id  name  text              category  date
1   Elen  This is text       1        2017-01-08
2   Elen  This is text       1        2017-01-08
3   Alina This is diff       2        2017-01-08
4   Alina This is diff       2        2017-07-10

In above case, ids 1 and 2 are obviuos duplicates since all the fields match. But, for me ids 3 and 4 belonging to category 2, where different dates doesn't matter, are also duplicates.

For such duplicate mechanism which is a better mechanism: to write multiple group by queries in mysql depending on categories or load data into jvm and compare in Java.

Please free to suggest any other better approach.

Aucun commentaire:

Enregistrer un commentaire