mysql 不同编码表字段比较时出现 illegal mix of collations

出错语句:
select * from `db1`.`table1` as `table1`,`db2.`table2` as `table2` where `table1`.`username`=`table1`.`username`;



table1和table2使用不同编码,提示illegal mix of collations ..

我的解决办法是
select * from `db1`.`table1` as `table1`,`db2.`table2` as `table2` where encode(`table1`.`username`,'mykey')=encode(`table1`.`username`,'mykey');

你可能感兴趣的:(java,mysql,db2)