可能重复:
如何从 MySQL 表中删除重复的行
我一直在互联网上寻找一个体面的答案,但我仍然不明白如何删除重复的行。我在下面有一个查询,有人可以告诉我如何正确实现删除重复行的功能吗?
有任何想法吗?
$bbc_values = array('http://www.bbc.co.uk/news/health-',
'http://www.bbc.co.uk/news/politics-',
'http://www.bbc.co.uk/news/uk-',
'http://www.bbc.co.uk/news/technology-',
'http://www.bbc.co.uk/news/world-',
'http://www.bbc.co.uk/news/england-',
'http://www.bbc.co.uk/news/northern_ireland-',
'http://www.bbc.co.uk/news/scotland-',
'http://www.bbc.co.uk/news/wales-',
'http://www.bbc.co.uk/news/business-',
'http://www.bbc.co.uk/news/education-',
'http://www.bbc.co.uk/news/science_and_enviroment-',
'http://www.bbc.co.uk/news/entertainment_and_arts-');
// BBC Algorithm
foreach ($links as $link) {
$output = array(
"title" => Titles($link), //dont know what Titles is, variable or string?
"description" => getMetas($link),
"keywords" => getKeywords($link),
"link" => $link
);
if (empty($output["description"])) {
$output["description"] = getWord($link);
}
$data = '"' . implode('" , "', $output) . '"';
if (substr_in_array($output, $bbc_values)) {
$result = mysql_query("INSERT INTO news_story (`title`, `description`, `keywords`, `link`) VALUES (" . $data . ")");
$delete = mysql_query("DELETE FROM news_story WHERE link='{$output['link']}'");
}
if (!substr_in_array($output, $bbc_values)) {
echo "Does not equal data";
}