mysql compare

COMPARISONS USING SIMILAR_TEXT() BUT SEE THE NOTES HERE BEFORE YOU USE IT!
 http://php.net/manual/en/function.similar-text.php#109507


<?php // RAY_temp_rgb192.html
error_reporting(E_ALL);
echo "<pre>";

// GETTING THE TITLES INTO THE ARRAY
$sql = 'SELECT title FROM my_table ORDER BY title';
$res = mysql_query($sql) or die("FAIL: $sql <br/> " . mysql_error());
while ($row = mysql_fetch_assoc($res))
{
    $string[] = $row['title'];
}

// SHOWING THE ARRAY OF TITLES
print_r($string);

// COMPARISONS USING SIMILAR_TEXT() BUT SEE THE NOTES HERE BEFORE YOU USE IT!
// http://php.net/manual/en/function.similar-text.php#109507
// COMPARISONS USING SIMILAR_TEXT
foreach ($string as $x)
{
    echo PHP_EOL . "TESTING <b>$x</b> WITH SIMILAR_TEXT()";

    // COMPARE TO THE OTHER STRINGS
    foreach ($string as $y)
    {
        $ss = similar_text($x, $y, $sp);
        echo PHP_EOL
        . "SIMILAR_TEXT() $x"
        . " HAS $ss CHARACTERS IN COMMON WITH $y "
        . '('
        . number_format($sp, 0)
        . '%)'
        ;
    }
}
echo PHP_EOL;

Open in new window





is there a way to do this in mysql
with less or no php
compare fields from the same column
similar by characters
LVL 1
rgb192Asked:
Who is Participating?
 
Cornelia YoderConnect With a Mentor ArtistCommented:
You might look at the MySQL function SOUNDEX().

Depending on what kind of "similiarity" you want, it might work for you.
0
 
rgb192Author Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.