Solved

MySQL DB - Duplicate records

Posted on 2013-01-03
5
201 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 500 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install

713 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