Illegal mix of collations for operation 'concat'

后端 未结 5 1849
再見小時候
再見小時候 2020-12-09 11:18

I\'m trying to execute this concat query in mysql

SELECT CONCAT(if(fName,fName,\'\'),Name) 
From Student

Error:

#127

5条回答
  •  天命终不由人
    2020-12-09 11:28

    Look like you have a miss use on the if statement there because it will resulting an undefined data type so the concat operation will fail as it different in data type. Try change the query by use ifnull instead.

    Try this query instead:

    SELECT concat(ifnull(fName,''),Name) From Student
    

    see the demo here http://www.sqlize.com/kfy85j8f1e

    for another reference read also http://forums.mysql.com/read.php?10,225982,225982#msg-225982

提交回复
热议问题