Search code examples
mysqlutf-8inner-joinlatin1

MySql INNER JOIN Query issues


I have been searching high and low to a solution for a "stupid" issue i am working with.

I have inherited a system from a former developer, and he was using LATIN1 as charset. Not much a problem, BUT i have always used UTF8, and now i need to make a INNER JOIN to a table with LATIN1 encoded data comparing TEXT field. This generates my issue, since i can not find a way to "compare" 2 textfields with eachother, since one is in UTF8 and the other in LATIN1

Is there any way around this issue, other than "changing the charset" for the LATIN1 tables.


Solution

  • You can use CAST mysql function to achieve this.

    for example,

    SELECT CAST(_latin1'test' AS CHAR CHARACTER SET utf8);
    

    reference link : http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html