解决mysql查询问题 [英] solve mysql query problem
本文介绍了解决mysql查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CONCAT(MONTHNAME(i.time), ' ', YEAR(i.time), c.categoryName)
错误代码:1271。操作'concat'的非法混合排序
Error Code: 1271. Illegal mix of collations for operation 'concat'
推荐答案
请参阅:
http://www.experts -exchange.com/Programming/Languages/Scripting/PHP/Q_26634253.html [ ^ ]
请查看eggyal发布的答案:http://stackoverflow.com/questions/3029321/troubleshooting-illegal-mix-of-collations-error-in-mysql [ ^ ]
据我所知,你不能混合使用数字和字符串值。您需要将其转换/转换为字符串
Please, see the answer posted by eggyal: http://stackoverflow.com/questions/3029321/troubleshooting-illegal-mix-of-collations-error-in-mysql[^]
As per i understand you can't mix numeric and string values. You need to convert/cast it to string
SELECT CONCAT(MONTHNAME(i.time), ' ', CONVERT(CHAR(4), YEAR(i.time)), c.categoryName) AS NewColName
FROM ...
另一个原因是每个表的排序规则不同。您可以使用 CONVERT
函数来解决它。
Another reason is different collation for each table. You can workaround it by using CONVERT
function.
SELECT CONVERT(c.categoryName USING utf8) AS Utf8CategoryName
这篇关于解决mysql查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文