How to configure schema mapping in MySQL for Japanese

I have a problem with sorting. I want to configure sorting to support Japanese. For example, when table.firstname has "あ", a query with "ぁ" should return a record. Thanks in advance.

+2
source share
1 answer

What, for example, is uppercase and lowercase, right?

mysql> SELECT 'あ' = 'ぁ' COLLATE utf8_general_ci; +---------------------------------------+ | 'あ' = 'ぁ' COLLATE utf8_general_ci | +---------------------------------------+ | 0 | +---------------------------------------+ mysql> SELECT 'あ' = 'ぁ' COLLATE utf8_unicode_ci; +---------------------------------------+ | 'あ' = 'ぁ' COLLATE utf8_unicode_ci | +---------------------------------------+ | 1 | +---------------------------------------+ mysql> SELECT 'あ' = 'ぁ' COLLATE utf8_unicode_520_ci; +-------------------------------------------+ | 'あ' = 'ぁ' COLLATE utf8_unicode_520_ci | +-------------------------------------------+ | 1 | +-------------------------------------------+ 

I recommend changing the COLLATION utf8_unicode_520_ci column COLLATION utf8_unicode_520_ci (or utf8mb4_unicode_520_ci ).

If you expect to include Chinese, then be sure to use utf8mb4 . (Perhaps this advice applies to kanji.)

+2
source

Source: https://habr.com/ru/post/1286767/


All Articles