このコードに「on duplicate key」を挿入して、重複した単語を削除するにはどうすればよいですか? または、あなたが知っているより良い方法はありますか?ありがとうございました!!
これは私のコードです:
function sm_list_recent_searches($before = '', $after = '', $count = 20) {
// List the most recent successful searches.
global $wpdb, $table_prefix;
$count = intval($count);
$results = $wpdb->get_results(
"SELECT `terms`, `datetime`
FROM `{$table_prefix}searchmeter_recent`
WHERE 3 < `hits` AND CHAR_LENGTH(`terms`) > 4
ORDER BY `datetime` DESC
LIMIT $count");
if (count($results)) {
foreach ($results as $result) {
echo '<a href="'. get_settings('home') . '/search/' . urlencode($result->terms) . '">'. htmlspecialchars($result->terms) .'</a>'.", ";
}
}
}