Why CONCAT() does not default to default charset in MySQL?

前端 未结 2 1966
你的背包
你的背包 2021-01-11 12:10

What is the reason, that using CONCAT() in pure UTF-8 environment MySQL still treats concatenated string (when some col in expression is for example int or date) as some oth

相关标签:
2条回答
  • 2021-01-11 12:52

    It's a well known bug in MySQL. It's fixed in MySQL 5.5

    See: http://bugs.mysql.com/bug.php?id=12030

    The issue stems from concatenating an integer with a varchar.

    The work around is to cast the id (integer) first to a char, and then concatenate, ie:

    SELECT CONCAT(cast(id as char), title) FROM utf8_test
    
    0 讨论(0)
  • 2021-01-11 13:11

    It probably is DBD::mysql issue/peculiarity. Try enabling utf8 in database handle as described in POD for DBD::mysql (mysql_enable_utf8 part).

    This old (Perl 5.8 times) article can also help.

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