Solved

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

Posted on 2010-11-23
2
1,263 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now