I do not think that what you want is directly possible. Sorting determines how you sort and compare your date. For your key, you want the two values โโto be perceived as different, but in your normal comparison, you want to be perceived as the same thing.
There is a trick around this, but when specifying your queries: just cast your results to utf8 without specifying sorting. This will start the result and return the default setting.
The following example shows what I mean:
mysql> show create table test_col; +----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | test_col | CREATE TABLE `test_col` ( `name` varchar(200) COLLATE utf8_bin DEFAULT NULL, UNIQUE KEY `ixuniq` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin | +----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> insert into test_col (name) values ('Y'),(unhex('c39d'));Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from test_col; +------+ | name | +------+ | Y | | ร | +------+ 2 rows in set (0.00 sec) mysql> select * from test_col where name='Y'; +------+ | name | +------+ | Y | +------+ 1 row in set (0.00 sec) mysql> select * from test_col where convert(name using 'utf8')='y';+------+ | name | +------+ | Y | | ร | +------+ 2 rows in set (0.00 sec)
source share