Solved

MySQL -- [nativecode=1271 ** Illegal mix of collations for operation 'concat']

Posted on 2010-11-23
2
1,299 Views
Last Modified: 2013-12-12
I have a large query in which I'm getting this error.

The weird thing is that the error occurs when my PHP grid component passes the query, but not when I paste the query into the MySQL command line.

And all my tables have the same collation, though not all use the same engine.

mysql> Select TAble_Name, Table_Collation, Engine from TABLES Where TABLE_SCHEMA        = 'wb_dev';
+-----------------------+-------------------+--------+
| TAble_Name            | Table_Collation   | Engine |
+-----------------------+-------------------+--------+
| wt_CompanySettings    | latin1_swedish_ci | MyISAM |
| wt_Expectation        | latin1_swedish_ci | MyISAM |
| wt_ExperienceLevel    | latin1_swedish_ci | MyISAM |
| wt_Login              | latin1_swedish_ci | MyISAM |
| wt_PaymentAgreement   | latin1_swedish_ci | InnoDB |
| wt_PerformanceLevel   | latin1_swedish_ci | MyISAM |
| wt_Settings           | latin1_swedish_ci | MyISAM |
| wt_URCriterion        | latin1_swedish_ci | InnoDB |
| wt_UserHistory        | latin1_swedish_ci | InnoDB |
| wt_UserReport         | latin1_swedish_ci | InnoDB |
| wt_UserSettings       | latin1_swedish_ci | MyISAM |
| wt_bulletin_alerts    | latin1_swedish_ci | MyISAM |
| wt_collectors         | NULL              | NULL   |
| wt_monthlynumber      | latin1_swedish_ci | InnoDB |
| wt_paymenttypes       | latin1_swedish_ci | InnoDB |
| wt_postpaymententries | latin1_swedish_ci | InnoDB |
| wt_tbldata            | latin1_swedish_ci | InnoDB |
| wt_tblhistory         | latin1_swedish_ci | InnoDB |
| wt_teams              | latin1_swedish_ci | InnoDB |
| wt_usertyes           | latin1_swedish_ci | InnoDB |
+-----------------------+-------------------+--------+
20 rows in set (0.64 sec)

Any idea where I'm going wrong?

Thanks!
select 'Daily Production' as Category, 
  Concat('<div style="background-color:',Color,';">$' , Format(Value, 2),'</div>') as Value , 
  Concat('$' ,Format(Office , 2)) as Office , 
  Concat('$' ,Format(Amount, 2)) as Expectation , 
  0 as DARTME 
FROM (Select PL.Color, PL.Performance, Value, Office, X.Amount 
FROM ( Select sum( Case When U.userName = 'APAY' Then ppe.Amount else 0 End) / (17) as Value, 
sum(ppe.Amount) / (17) / 36 as Office 
from wt_postpaymententries ppe Inner Join wt_PaymentAgreement PA on ppe.AgreementID = PA.AgreementID Inner Join wt_collectors U on U.ID = PA.CollectorID 
WHERE Month(PA.EntryDate) = Month('2010-11-22') and Year(PA.EntryDate) = Year('2010-11-22') 
) V Inner Join wt_collectors U on U.UserName = 'APAY' INNER JOIN wt_Expectation X on X.Experience = U.Experience AND X.Category='Daily' INNER JOIN wt_PerformanceLevel PL on V.Value >= PL.MinPercent * X.Amount 
Order by PL.MinPercent desc Limit 1 )G

Open in new window

0
Comment
Question by:Daniel Wilson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 32

Author Comment

by:Daniel Wilson
ID: 34198191
Pulling the HTML out of the CONCAT ...
select 'Daily Production' as Category, Concat(Color,' $' , Format(Value, 2)) as Value ...
gives me a more explicit error message:
[nativecode=1270 ** Illegal mix of collations (latin1_swedish_ci,IMPLICIT), (utf8_unicode_ci,COERCIBLE), (utf8_unicode_ci,COERCIBLE) for operation 'concat']
0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 0 total points
ID: 34198231
Looks like CONVERT will get it for me:
select 'Daily Production' as Category, Concat(Convert(Color USING utf8),' $' , Format(Value, 2)) as Value
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question