Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql - Why "n" is included when I search for "ñ"?

Tags:

sql

mysql

I have a problem. When I have this code SELECT FIRST_NAME FROM CONTACT WHERE FIRST_NAME LIKE '%ñ%' why is it returning all FIRST_NAME that has n without ñ. Im expecting only those that have ñ. Thanks in advance.

like image 617
TheOnlyIdiot Avatar asked Nov 13 '12 07:11

TheOnlyIdiot


2 Answers

SELECT FIRST_NAME 
FROM CONTACT 
WHERE FIRST_NAME LIKE '%ñ%' COLLATE utf8_spanish_ci 
  • SQLFiddle Demo
like image 160
John Woo Avatar answered Sep 18 '22 10:09

John Woo


Try to use a BINARY operator to compare strings in binary way -

SELECT FIRST_NAME FROM CONTACT WHERE FIRST_NAME LIKE BINARY '%ñ%'
like image 38
Devart Avatar answered Sep 20 '22 10:09

Devart