1
2
3
4
5
6
7
8
9
10
11
DELIMITER //
CREATE FUNCTION `remove_dups_mysql` (str VARCHAR(70)) RETURNS varchar(70) CHARSET latin1
BEGIN

SET str = LOWER(str);

RETURN REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(str, 'aa', 'a'), 'bb', 'b'), 'cc', 'c'), 'dd', 'd'), 'ff', 'f'), 'gg', 'g'), 'll', 'l'), 'mm', 'm'), 'nn', 'n'), 'oo', 'o'), 'pp', 'p'), 'rr', 'r'), 'ss', 's'), 'tt', 't'), 'vv', 'v'), 'zz', 'z');
END
//

DELIMITER ;