mysql表之间关联查询报错:1267 - Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_general_c
1.问题描述:在进行两个数据表联合查询时,由于数据库编码不一致,导致查询的时候报错1267 - Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and(utf8mb4_general_ci,IMPLICIT) for operation ‘=’2.问题解决需要增加关联字段的转换即可语法convert(‘column’ using’ u
1.问题描述:
在进行两个数据表联合查询时,由于数据库编码不一致,导致查询的时候报错
1267 - Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and
(utf8mb4_general_ci,IMPLICIT) for operation ‘=’
2.问题解决
需要增加关联字段的转换即可
- 语法
- convert(‘column’ using’ utf8)
SELECT
dc.id,dc.data_id,dc.data_ruid,dc.course_ruid,
c.name as course_name,
(select department_ruid from department_course dc where dc.course_id= c.id ) as department_ruid,
(SELECTnameFROMua_sysinfo.department WHERE RUID = CONVERT(department_ruid using utf8) ) as department_name
FROM
data_course dc ,course c where dc.course_ruid=c.ruid and dc.data_id = 379277
3.扩展
mysql 排序方法 “order by” 排序规则
| 编码 | 排序规则 |
|---|---|
| utf-8mb4 | 按英文字母a,b,c规则排序 |
| gbk | 按汉字拼音首字母排序 |
更多推荐



所有评论(0)