Skip to content

Instantly share code, notes, and snippets.

@ef4
ef4 / gist:fe2e8e5b6e75266e3c2d
Last active September 3, 2020 12:48
Gist as iframe
<iframe src="data:text/html;charset=utf-8,%3Cbody%3E%3Cscript%20src%3D%22https%3A%2F%2Fgist.github.com%2Fef4%2Ffe2e8e5b6e75266e3c2d.js%22%3E%3C%2Fscript%3E%3C%2Fbody%3E">
@Kovah
Kovah / mysql-levenshtein.sql
Created February 22, 2017 21:29
Levenshtein function for MySQL
-- Levenshtein function
-- Source: https://openquery.com.au/blog/levenshtein-mysql-stored-function
-- Levenshtein reference: http://en.wikipedia.org/wiki/Levenshtein_distance
-- Arjen note: because the levenshtein value is encoded in a byte array, distance cannot exceed 255;
-- thus the maximum string length this implementation can handle is also limited to 255 characters.
DELIMITER $$
DROP FUNCTION IF EXISTS LEVENSHTEIN $$
CREATE FUNCTION LEVENSHTEIN(s1 VARCHAR(255) CHARACTER SET utf8, s2 VARCHAR(255) CHARACTER SET utf8)