Possible Duplicate:
Remove duplicates using only a MySQL query?
I have a table with different pages but some of them are duplicates. The only way to determine duplicates are by title. I run the code below and it works perfectly:
<?php
mysql_connect("localhost", "root", "root") or die(mysql_error());
mysql_select_db("old") or die(mysql_error());
$result = mysql_query("SELECT pagetitle, COUNT( * ) c
FROM cms_site_content
GROUP BY pagetitle
HAVING c >1") or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['id'].'-'.$row['pagetitle'].'<br />';
}
?>
My question is: How can I erase duplicates and keep only one entry. For example if I have an article called "Duplicate Article" and the result is
Duplicate Article: 3
I want to keep only one.