Wednesday, July 23, 2008

How to find duplicate rows in mysql using php

There are times when you need to find duplicate rows or records in a mysql table.
This mostly happens when you import data sources from out side(CSV,EXCEL,SQL)
Following code will show you how to find duplicates,



select count(*) as num, ID, Name from table
group by ID,Name
having count(*) > 1



This code will group the given column and see if the grouped columns have more than one record

+-----+------+------------+
| num |ID | Name |
+-----+------+------------+
| 3 | 1 | Kuppiya |
+-----+------+------------+
| 2 | 3 | Apple |
+-----+------+------------+



Get custom programming done at GetAFreelancer.com!

1 comment: