create or alter function alfaNum (texto varchar(100)) returns varchar(100)
as
declare variable stAux varchar(100) = '';
BEGIN
stAux = upper(:texto);
stAux = replace(stAux, 'Á', 'A');
stAux = replace(stAux, 'À', 'A');
stAux = replace(stAux, 'Ã', 'A');
stAux = replace(stAux, 'Â', 'A');
stAux = replace(stAux, 'Ä', 'A');
stAux = replace(stAux, 'É', 'E');
stAux = replace(stAux, 'Ê', 'E');
stAux = replace(stAux, 'Ë', 'E');
stAux = replace(stAux, 'Ï', 'I');
stAux = replace(stAux, 'Í', 'I');
stAux = replace(stAux, 'Î', 'I');
stAux = replace(stAux, 'Ö', 'O');
stAux = replace(stAux, 'Ó', 'O');
stAux = replace(stAux, 'Õ', 'O');
stAux = replace(stAux, 'Ô', 'O');
stAux = replace(stAux, 'Ò', 'O');
stAux = replace(stAux, 'Ú', 'U');
stAux = replace(stAux, 'Ü', 'U');
stAux = replace(stAux, 'Ç', 'C');
stAux = replace(stAux, '&', 'E');
stAux = replace(stAux, '´', ' ');
stAux = replace(stAux, '^', ' ');
stAux = replace(stAux, '~', ' ');
stAux = replace(stAux, 'Æ', 'A');
stAux = replace(stAux, 'Ñ', 'N');
stAux = replace(stAux, 'Ý', 'Y');
stAux = replace(stAux, 'ª', 'A');
stAux = replace(stAux, 'º', 'O');
RETURN Upper(stAux);
END
Try to use
WHERE nome LIKE '%Maria Magalhaes%'
; I don’t know if this solves but I think it doesn’t need anything more than what you are already doing, because mysql already compares that "a" and "ã" are also a valid result.– RFL
SELECT * FROM usuarios where NOME LIKE utf8_unicode_ci 'Maria Magalhaes'
– Diego Souza
I don’t know why your Mysql looks like this. Try changing the encoding. In my search
João
,joao
,Joao
, with accent, without accent, Lcase, Ucase and sought the wordJoão
.– Diego Souza
you can also do direct code to work too @Wallacemaxters
$con->exec('SET NAMES utf8');
– RFL
See, for accents it seems to work, I don’t know about the
ç
...: http://stackoverflow.com/questions/8647080/accent-insensitive-search-query-in-mysql . Keep in mind that a search as you want to do can bring performance problems, even if the original field is indexed. There are cases so the solution is to create a new "sanitized" column (without accents andç
, for example) and index it as well, doing the searches using this new column. In general, this is the approach I believe is the most adopted.– Dherik