在执行 SQL 语句中有比较两个表的字段时,如下图出现 Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) 错误。
在这里插入图片描述
原因是表 bas_parameter_item 编码类型是 utf8_general_ci ,而表 bas_parameter_copy1 编码类型是 utf8_unicode_ci 。以下是我找到的解决方法:
1. 查询时进行数据类型转换 CONVERT(BPA.parameter_id USING utf8) COLLATE utf8_unicode_ci
在这里插入图片描述
2. 将两个表的编码保持一致,并且查询效率大大提升

alter table bas_parameter_copy1 convert to character set utf8 collate utf8_general_ci

在这里插入图片描述