Solved

MySQL DB - Duplicate records

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now