alko
alko

Reputation: 48317

Mysql incorrect lookup with utf8 varchar field

I do have a UTF8 InnoDB db with a table, say 'words':

> desc words;
+-------+-------------+------+-----+---------+----------------+
| Field | Type        | Null | Key | Default | Extra          |
+-------+-------------+------+-----+---------+----------------+
| id    | int(11)     | NO   | PRI | NULL    | auto_increment |
| name  | varchar(50) | NO   | UNI | NULL    |                |
+-------+-------------+------+-----+---------+----------------+

and when I execute a query

select * from word where name = 'Télécom';

I get a strange result I can't explain:

+------+---------+
| id   | name    |
+------+---------+
| 4980 | telecom |
+------+---------+

Thanks in advance!

Upvotes: 0

Views: 113

Answers (1)

Maxim Krizhanovsky
Maxim Krizhanovsky

Reputation: 26699

It's because of the collation - it defines how the characters are compared and which are considered equal. It may be desired result, and it may not - in the last case, use binary collation and only strictly equal strings will be considered equal. But keep in mind, binary collations are also case-sensitive

Upvotes: 2

Related Questions