Find duplicate records in php mysql

To find duplicate records in php mysql database use this query.
It will list all duplicate entries which occurs more than once.

  
  $sql = "SELECT email FROM users WHERE email in (
          SELECT email FROM users GROUP BY email 
          HAVING count(email) > 1)";
  $result = mysql_query($sql);
  while($row = mysql_fetch_array($result)){
      echo $row['email']."<br>";
  } 

Find duplicate records in php mysql Find duplicate records in php mysql Reviewed by JS Pixels on July 16, 2011 Rating: 5

No comments:

Altaf Web. Powered by Blogger.