MySQL - Why are COLLATION rules ignored by LIKE operator for German ß character

后端 未结 1 1285
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 02:12

I\'m running the following select statements on MySQL 5.0.88 with utf8 charset and utf8_unicode_ci collation:

SELECT * FROM table WHERE surname = \'abcß\';

         


        
相关标签:
1条回答
  • 2020-12-11 03:09

    Per the SQL standard, LIKE performs matching on a per-character basis, thus it can produce results different from the = comparison operator:

    mysql> SELECT 'ä' LIKE 'ae' COLLATE latin1_german2_ci;
    +-----------------------------------------+
    | 'ä' LIKE 'ae' COLLATE latin1_german2_ci |
    +-----------------------------------------+
    |                                       0 |
    +-----------------------------------------+
    mysql> SELECT 'ä' = 'ae' COLLATE latin1_german2_ci;
    +--------------------------------------+
    | 'ä' = 'ae' COLLATE latin1_german2_ci |
    +--------------------------------------+
    |                                    1 |
    +--------------------------------------+
    

    Source: http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like

    0 讨论(0)
提交回复
热议问题