2

My query is:

SELECT * FROM enwiki.page where title_text = 'drug';

One of the results I got has the tilte_text = 'Drûg'. How can I prevent that?

Andi Keikha
  • 1,246
  • 2
  • 16
  • 37

1 Answers1

5

Use the correct collate (eg: utf8_general)

SELECT * FROM enwiki.page where title_text = 'drug' COLLATE utf8_general;

MySQL has a CHARSET that tells how does the DB store the values internally. On the other handthe COLLATION instruct the DB how to search, compare and order the data.

For example, if you use any collation that ends in _ci (that stands for case insensitive, and you search like this:

SELECT name FROM myTable WHERE name LIKE %Home%;

You can receive this back:

  • Home
  • HOME
  • homE
  • home

and so on...

Same thing happens with the symbols or accents of the letters (in your case û). You have to use a collation that consider them.

javierfdezg
  • 2,087
  • 1
  • 22
  • 31