Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
CONCAT(MONTHNAME(i.time), ' ', YEAR(i.time), c.categoryName) 


Error Code: 1271. Illegal mix of collations for operation 'concat'
Posted
Updated 30-Oct-14 3:18am
v3
Comments
Herman<T>.Instance 30-Oct-14 8:02am    
what collations are used for table i and c ?
[no name] 30-Oct-14 8:02am    
is it MySQL or SQL Server or what ???
Navi.jsp 30-Oct-14 9:04am    
mysql server

 
Share this answer
 
Comments
Navi.jsp 30-Oct-14 10:18am    
i am using java and mysql
King Fisher 31-Oct-14 0:13am    
you mentioned it's in MySQL Query
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
SQL
SELECT CONCAT(MONTHNAME(i.time), ' ', CONVERT(CHAR(4), YEAR(i.time)), c.categoryName) AS NewColName
FROM ...


Another reason is different collation for each table. You can workaround it by using CONVERT function.
SQL
SELECT CONVERT(c.categoryName USING utf8) AS Utf8CategoryName
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900