2

I have a table set up where fields are TEXT utf8_general_ci.

The field data is set to Jovíkhan (where the í is actually ALT-161).

I do a search for Jovikhan (regular i, NOT ALT-161), I'm returned all the results as if I had actually used the ALT-161 í.

SELECT * FROM Table WHERE Field = 'Jovikhan';

Driving me a little bonkers here... I'm getting this issue directly in phpMyAdmin currently... why would it return those fields, especially if I'm using = 'Jovikhan' vs. LIKE '%Jov%'?

elixenide
  • 44,308
  • 16
  • 74
  • 100
James Young
  • 55
  • 1
  • 8
  • possible duplicate of [What are the diffrences between utf8\_general\_ci and utf8\_unicode\_ci?](http://stackoverflow.com/questions/1036454/what-are-the-diffrences-between-utf8-general-ci-and-utf8-unicode-ci) – GolezTrol Jun 08 '15 at 18:58
  • possible duplicate of [How to conduct an Accent Sensitive search in MySql](http://stackoverflow.com/questions/500826/how-to-conduct-an-accent-sensitive-search-in-mysql). – GolezTrol Jun 08 '15 at 19:01

1 Answers1

2

The _ci in utf_general_ci means case-insensitive. This causes MySQL to treat i and í as identical. You need to add COLLATE utf8_bin to your query:

SELECT * FROM Table WHERE Field = 'Jovikhan' COLLATE utf8_bin;

For more discussion, see this post.

Community
  • 1
  • 1
elixenide
  • 44,308
  • 16
  • 74
  • 100
  • Why do you refer to another thread which is basically the same question as OP's, and the same answer as yours? Please close as duplicate instead. – GolezTrol Jun 08 '15 at 19:02
  • 1
    @GolezTrol I felt the first part of the accepted answer on that question could be stated more clearly. I am, however, voting to close as well. – elixenide Jun 08 '15 at 19:03
  • Thank you very much... I did do a search but didn't really see anything stand out... maybe you shouldn't mark as duplicate as someone might find this useful. – James Young Jun 08 '15 at 19:39