Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
08-18-2009, 08:43 PM #1
Find all duplicates in a mysql field
If you are ever in need of finding duplicates in a mysql field but dont want to open phpmyadmin you can simply do this.
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
$result = mysql_query("select field, count(field) as cnt
group by field
having cnt > 1
order by cnt; ")
while($row = mysql_fetch_array( $result ))
Of course change table and field in the snippet to your own.