Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write a query to to delete duplicate rows?

Answer Posted / rakesh dongarwar

$query="SELECT * FROM `emails` ORDER BY `email` ASC LIMIT 0, 30";
mysql_query($query);
$result=mysql_query($query);

$numrows=mysql_num_rows($result);

$totalemailsdeleted=0;
$i=1;
$i2=0;
while($i2 < $numrows)
{
$id=mysql_result($result, $i2, id);
$email=mysql_result($result, $i2, email);
while($i < $numrows)
{
$idcompare=mysql_result($result, $i, id);
$emailcompare=mysql_result($result, $i, email);
if($emailcompare == $email)
{
$query="DELETE FROM `emails` WHERE `id` = '$idcompare' LIMIT 1";
mysql_query($query);
$emailsdeleted.="$emailcompare<br>";
$totalemailsdeleted++;
$numrows=mysql_num_rows($result);
}
else
{
}
$i++;
}
$i2++;
}

Is This Answer Correct ?    4 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me what is the difference between unset() and unlink()?

997


How to retrieve values out of an array?

967


What function should you use to join array elements with a glue string?

925


What is the difference between exception::getmessage and exception::getline?

911


How do you trim spaces in excel?

965


What is the name of the scripting engine that powers PHP?

1179


How do I run a php file?

914


Is echo a function in php?

939


What is the difference between explode () and split () functions in php?

1062


Is null or empty c#?

884


Can we use get instead of post?

908


What is strlen function in php?

973


What is factory pattern in php?

872


What is csrf token and why it is required?

910


How to download files from an external server with code in php?

844