Reputation: 17049
There is a table with 2 records - u
and ù
:
CREATE TABLE `tbl` (`text` text NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8;
INSERT INTO `tbl` (`text`) VALUES ('u'), ('ù');
I want to select row with ù:
SELECT * FROM `tbl` WHERE `text` = 'ù';
The result is
+------+
| text |
+------+
| u |
| ù |
+------+
What is the problem here? How can I work with such characters?
Upvotes: 2
Views: 107
Reputation: 9256
This is to do with the collation used when mysql compares values. If you run the following query, you'll see which collation is in effect:
show collation where Charset = 'utf8';
One of those should have a Default
value of yes
. In my case it's utf8_general_ci
. This collation uses Unicode ordering to equate characters with accents and those without.
If you run the following query:
SELECT * FROM `tbl` WHERE `text` = 'ù' collate utf8_bin;
Then you'll only get one row back. There's a lot more information in the MySQL documentation.
Upvotes: 4