Mysql - Illegal Mix Of Collations (utf8_general_ci,coercible) And (latin1_swedish_ci,implicit) For Operation 'union'
How do I fix that error once and for all? I just want to be able to do unions in MySQL. (I'm looking for a shortcut, like an option to make MySQL ignore that issue or take it's
Solution 1:
Not sure about mySQL but in MSSQL you can change the collation in the query so for example if you have 2 tables with different collation and you want to join them or as in you situation crate UNION you can do
select column1 from tableWithProperCollation
unionallselect column1 COLLATE SQL_Latin1_General_CP1_CI_AS from tableWithDifferentCollation
Of course SQL_Latin1_General_CP1_CI_AS is just an example of collation you want to "convert" to
Solution 2:
Thanks Kristof. In this case it was being caused by selecting a literal in the first select, and not from any different table collations.
Ironically I got it working by following this old blog post I made for that issue.
Solution 3:
A fix I found that seems to be an easy fix is to alter the entire database that's giving you problems. I'm thinking this might not be the best way to do it, but it works for me and it's easy. I rune this command in MySQL:
ALTER DATABASE databasename COLLATE utf8_unicode_ci;
Post a Comment for "Mysql - Illegal Mix Of Collations (utf8_general_ci,coercible) And (latin1_swedish_ci,implicit) For Operation 'union'"