Hay .. I want to remove Simillar Data from my database . Currently Im now able to delete Duplicate data from my database and keep one .
$sql = "UPDATE `clf_ads` SET `enabled`= '0' WHERE adid NOT IN (SELECT * FROM (SELECT MAX(adid) FROM clf_ads GROUP BY adtitle) x)";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully";
} else {
echo "Error deleting record: " . $conn->error;
}
$conn->close();
?>
How to delete data which match 80% similar?
There is no such thing as 80% similar, unless you have a specific value you're testing against. For example, if your table has the following:
-----------------------------------
| adid | adtitle |
-----------------------------------
| 1 | 'this is an ad title' |
| 2 | 'this is the ad title' |
| 3 | 'that is the ad title' |
Then, if you're just counting similarity between words, ad 1 is 80% similar to ad 2, and 60% similar to ad 3. However, ad 2 is 80% similar to ad 1, and 80% similar to ad 3.
Therefore, what your asking for currently is not possible unless you single out an ad you want to keep, and then compare the similarity of other titles with that title.
To compare the similarity between fields in MySQL, you'll want to take a look at this question: how to compute similarity between two strings in MYSQL