MySql - Select from - Don't Show Duplicate Words - maybe "on duplicate key"?

Posted by ali on Stack Overflow See other posts from Stack Overflow or by ali
Published on 2010-03-16T14:37:48Z Indexed on 2010/03/16 15:01 UTC
Read the original article Hit count: 278

Filed under:
|
|

hi, how can I insert "on duplicate key" in this Code to remove duplicate words? or is there a better method that you know? thank you!!

this is my code:

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>'.", ";
        }

    }
}

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql