Skip to content

Instantly share code, notes, and snippets.

@dannykopping
Created October 8, 2011 16:33
Show Gist options
  • Save dannykopping/1272510 to your computer and use it in GitHub Desktop.
Save dannykopping/1272510 to your computer and use it in GitHub Desktop.
Similarity 3
mysql> SELECT *, jaro_winkler_similarity(`name`, "mr whiskers") AS score
-> FROM (SELECT id, `name` FROM CatName WHERE `name` LIKE "%mr%" OR `name` LIKE "%whiskers%") AS likeMatches
-> ORDER BY score DESC
-> LIMIT 10;
+-------+----------------+------------------+
| id | name | score |
+-------+----------------+------------------+
| 10105 | Mr. Whiskers | 97.7777779102325 |
| 10108 | Mr. Wiskers | 95.1515138149261 |
| 16204 | Whiskers | 90.9090936183929 |
| 10091 | Mr. Snickers | 85.5218827724457 |
| 10899 | Oprah Whiskers | 82.44588971138 |
| 10068 | Mr. Mister | 82.3030292987823 |
| 10106 | Mr. Winkie | 82.3030292987823 |
| 9998 | Mr Monster | 80.060601234436 |
| 10089 | Mr. Sleepers | 79.191917181015 |
| 10023 | Mr. Chips | 78.9898991584778 |
+-------+----------------+------------------+
10 rows in set (0.28 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment