View Single Post
  #4 (permalink)  
Old 05-01-08, 12:52 PM
amigura's Avatar
amigura amigura is offline
Newbie Coder
 
Join Date: Feb 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Code:
CREATE TABLE emails_temp AS SELECT * FROM emails WHERE 1 GROUP BY email;

DROP TABLE emails;

RENAME TABLE emails_temp TO emails;
be careful in doing this as it will kill all your primary,index, auto increm


this is a rework of wat you were trying to do
Code:
$sql = "SELECT id,count(email) as etot FROM emails group by email having etot > 1"; 
$result = mysql_query( $sql );while( $row = mysql_fetch_array( $result ) ) {

$id.= $row["id"].',';
//$delem = "delete from emails where id = '".$row["id"]."'"; $delquery = mysql_query($delem);
}

$id=substr($id, 0, -1);
$delem = "delete from emails where id in ($id)"; $delquery = mysql_query($delem);
__________________
amigura.co.uk
Reply With Quote