rgb192
asked on
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
is there a way to do this in mysql
with less or no php
compare fields from the same column
similar by characters
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;
is there a way to do this in mysql
with less or no php
compare fields from the same column
similar by characters
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have a similar question
https://www.experts-exchange.com/questions/27860241/mysql-similar-text-character-comparison.html