Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySQL DB - Duplicate records

Posted on 2013-01-03
5
Medium Priority
?
205 Views
Last Modified: 2013-01-04
Hi all,

I have a MYSQL Db, there's a table with a field name of 'Email'.

How would I find out if there's any duplicates in that table, and if so, what they are?  I know querying DISTINCT will stop dups from showing, but I want to get rid of them, not just suppress them.

Thanks,
0
Comment
Question by:Rush_2112
  • 5
5 Comments
 
LVL 21

Expert Comment

by:oleggold
ID: 38740455
select val1.val2,count(1) from table
group by  val1.val2,
having ,count(1) f>1
0
 
LVL 21

Accepted Solution

by:
oleggold earned 2000 total points
ID: 38740459
mistype, heres:
[
select val1.val2,count(1) from table
group by  val1.val2,
having count(1) >1

Open in new window

0
 
LVL 21

Expert Comment

by:oleggold
ID: 38740472
In oracle I'd use rowid to clean it up,in mysql something similar
create view mydups as
select val1.val2,count(1) from table
group by  val1.val2,
having count(1) >1
0
 
LVL 21

Expert Comment

by:oleggold
ID: 38740489
then select d1.uniq_rowid,d2.uniq_rowidfrom mydups d1,mydups  d2
where d1.val1=d2.val1 and d1.val2=d2.val2
and d1.uniq_rowid>d2.uniq_rowid
0
 
LVL 21

Expert Comment

by:oleggold
ID: 38740490
other way create unique index on table diabled, enable it with expetion into exptions table , delete all occurences from exception table
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month8 days, 19 hours left to enroll

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question