views:

27

answers:

3

Hi! I'm looking for a tool that allows me to easily manage duplicate entries in the MySQL database.

In a sense, I don't want to make my columns 'UNIQUE', but I want to review the records that happen to have exactly the same value in a column.

It would be nice if I could craft such an SQL query that shows only such records using the usual interface.

+1  A: 

Should be possible to select them with a query:

select myColumn, count(myColumn) as myCount from myTable group by myColumn having myCount > 1 order by myCount; 
hollsk
Almost perfect! Could you share two more tidbits:1) Getting to see all the records that happen to share the same myColumn value, instead of just the first one?2) Getting to group by a combination of columns?
qdot
hm - the above code should return all duplicates as is. What number does count() give you? Also group by extra colums just by adding another column name with a comma - 'group by myColumn, myOthercolumn having...'
hollsk
A: 

I'm not sure about the interface, but this tool certainly does the former: http://www.dodownload.com/business+manage/access+database/mysql+delete+remove+duplicate+entries+software.html

sdtechcomm
+1  A: 

To get duplicates, just use a self-join on the table :

select t1.id, t2.id, t1.value
from table t1
inner join table t2 on t1.value=t2.value
where t1.id < t2.id

The t1.id < t2.id will make sure every duplicate will only appear once.

wimvds
Devious, but brilliant! Now I'm torn between awarding 'answer' to you or to hollsk!
qdot