This article describes a PHP query and deletes a database of multiple-column duplicate data methods. Share to everyone for your reference, specific as follows:
<?php
$con = mysql_connect ("localhost", "root", "");
if (! $con)
{
die (' Could not connect: '. Mysql_error ());
}
$db _selected = mysql_select_db ("test_db", $con);
if (! $db _selected)
{
die ("can/" T use test_db: ".) Mysql_error ());
}
$sql = "SELECT * from friend";
$result =mysql_query ($sql, $con);
while ($myrow =mysql_fetch_row ($result))
{
$arr _data[$myrow [0]]= $myrow [1]. " -". $myrow [2];
}
$arr _unique=array_unique ($arr _data);
$arr _rep=array_diff_assoc ($arr _data, $arr _unique);
Displays the amount of
echo count ($arr _data). -". Count ($arr _unique);
foreach ($arr _rep as $key => $value) {
$sql _del = "DELETE from friend WHERE id = ' {$key} '";
$result =mysql_query ($sql _del, $con);
Some code
mysql_close ($con);
? >
For more information about PHP interested readers can view the site topics: "PHP object-oriented Programming Introduction Tutorial", "PHP string (String) Usage Summary", "Php+mysql Database operation Introduction Tutorial" and "PHP Common database Operation tips Summary"
I hope this article will help you with the PHP program design.