Jump to content

Remove duplicates


AV1611

Recommended Posts

well id do ....

 

 

$records = array();
$same = 0;

select * from table

while $row = mysqli_fetch_array{

$records[] = $row
}






select * from table

while $row = mysql_fetch_array($query) {


foreach $row as $field => $value {

foreach($records as $record)

if($row[$field] == $record[field]) {
         $same = 1;

}

if($same == 0)       {

break;

}

}

if($same == 1) { delete_duplicate($row['id']); }

$records[] = $row


}

 

 

what it does is loops through every field in the database and checks every field in each row, against all the other rows......... then if all the fields are the same then call a function that you create, that deltes the duplicate

 

 

howver thats only rough, dont rely on it though

Link to comment
Share on other sites

Well this will find the dups ;) (for email)

 

SELECT email
FROM users
GROUP BY email
HAVING ( COUNT(email) = 1 )

 

 

Wouldn't the code have to be:

FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )

 

So it could find the records that are GREATER than 1? You put equal...not sure which one it would be.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.