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

前端 未结 2 1983
你的背包
你的背包 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
    

提交回复
热议问题