Troubleshooting of MySQL errors: Difference between revisions

Jump to navigation Jump to search
m
(+Error 1267)
Line 193: Line 193:


== ERROR 1267: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation 'concat' ==
== ERROR 1267: Illegal mix of collations (utf8mb4_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation 'concat' ==
Error condition: Tried to concat different data type e.g. CONCAT(string, int)
Error condition: Tried to concat different type of data e.g. CONCAT(string, int)


Solution: {{kbd | key =<nowiki>SELECT CONCAT(`string_column`, CONVERT(`int_column`, CHAR))</nowiki>}} or {{kbd | key =<nowiki>SELECT CONCAT(`string_column`, CAST(`int_column` AS CHAR))</nowiki>}}<ref>[https://stackoverflow.com/questions/15368753/cast-int-to-varchar mysql - Cast int to varchar - Stack Overflow]</ref><ref>[http://blog.51cto.com/bian5399/1092772 mysql字符集问题:Illegal mix of collations-每天让自己进步一点-51CTO博客]</ref>
Solution: {{kbd | key =<nowiki>SELECT CONCAT(`string_column`, CONVERT(`int_column`, CHAR))</nowiki>}} or {{kbd | key =<nowiki>SELECT CONCAT(`string_column`, CAST(`int_column` AS CHAR))</nowiki>}}<ref>[https://stackoverflow.com/questions/15368753/cast-int-to-varchar mysql - Cast int to varchar - Stack Overflow]</ref><ref>[http://blog.51cto.com/bian5399/1092772 mysql字符集问题:Illegal mix of collations-每天让自己进步一点-51CTO博客]</ref>

Navigation menu