title: Illegal mix of collations in mySQL
body: <p>I need to transfer a column from one table to another. The source table has a different collation than the target table (latin1_general_ci and latin1_swedish_ci). </p>
  
  <p>I use</p>
  
  <pre><code>UPDATE target 
  LEFT JOIN source ON target.artnr = source.artnr 
  SET target.barcode = source.barcode
  </code></pre>
  
  <p>I get an "illegal mix of collations". </p>
  
  <p>What is a quick fix to get this working without having to change either table? I tried CONVERT and COLLATE to run the whole operation in UTF-8, but that didn't help. "barcode" contains numeric data only (even though they all are VARCHARs), so there are no collation worries either way. I need to do this just once.</p>
  
  <blockquote>
    <p>Edit: I sorted it using a <code>CAST(fieldname as unsigned)</code> on every field involved. I was able to do that in this case because only numeric data was affected, but it would be nice to know a more general approach to this, so I am leaving the question open.</p>
  </blockquote>