Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

815 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

9 Experts available now in Live!

Get 1:1 Help Now