Thursday, July 9, 2009

Find Duplicate Data

1. how to find a duplicate records from table?
Lets the table name is report and its have a two field, id and type.
type contain a numbers of duplicate records...

first retrieve the all records from table:
select type,id from report;








typeid
php1
php2
mysql3
mysql4
lamp5
lamp6


use command:
select count(type), id from report group by type having count(type)>1;

get the records like this:






count(type)id
21
22
23


the above table explains the id 1,2,3 contain the 2 number of duplicates data.

No comments: