How to find duplicate records?

A 5 star hangout for overworked and underpaid system admins.
Post Reply
Kinjal
Posts: 7
Joined: 2016/05/24 12:08:33

How to find duplicate records?

Post by Kinjal » 2016/06/01 12:46:45

Database Table that contains two different records for every user id, but value in the column "Dept" has dissimilar values for every record. I want to yield all records which comprises duplicate UserName

userid UserName Dept
111 JDe Accounts
111 JDe Travel
222 ML Bussiness
222 ML Vacation
333 BPD Travel
444 MGb Business

[Moderator: moved to CentOS Social as this is not a CentOS question]

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: How to find duplicate records?

Post by gerald_clark » 2016/06/01 13:17:33

This is not CentOS problem, and definitely not a network issue.
You should ask in a forum for whatever database you are using.

User avatar
TrevorH
Forum Moderator
Posts: 26292
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to find duplicate records?

Post by TrevorH » 2016/06/01 15:20:27

What database are you using?
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

aks
Posts: 2807
Joined: 2014/09/20 11:22:14

Re: How to find duplicate records?

Post by aks » 2016/06/01 15:53:06

SELECT UserName, COUNT(*) FROM <TABLE> UserName HAVING COUNT(*) > 1;

tamarin_t
Posts: 7
Joined: 2016/05/25 06:06:21

Re: How to find duplicate records?

Post by tamarin_t » 2016/06/07 14:03:03

Traditional unix text processing utils `cut` to select individual fields and `uniq` to filter duplicate records would do this.

I would use a relational database for anything other than a one off task requiring minimal processing - `sqlite` is installed on most systems.

Post Reply