在t_employee表中,练习使用concat函数连接字符串时,

mysql> select concat('工号为:',fnumber,'的员工的幸福指数:',fsalary/(fage-21))
-> from t_employee;
1271 - Illegal mix of collations for operation 'concat'   报错

在网上查看了相关错误文章发现是字段得字符集有问题,我这里的fnumber字段的字符集是latin1,而字段操作默认为UTF8的编码。 绝对统一使用UTF-8 。

修改了字符集为utf-8后再次运行SQL命令

mysql> select concat('工号为:',fnumber,'的员工的幸福指数:',fsalary/(fage-21))
-> from t_employee;
+-----------------------------------------------------------------+
| concat('工号为:',fnumber,'的员工的幸福指数:',fsalary/(fage-21)) |
+-----------------------------------------------------------------+
| 工号为:dev001的员工的幸福指数:2075.000000 |
| 工号为:dev002的员工的幸福指数:328.685714 |
| 工号为:HR001的员工的幸福指数:1100.400000 |
| 工号为:HR002的员工的幸福指数:1300.090000 |
| 工号为:IT001的员工的幸福指数:557.142857 |
| 工号为:IT002的员工的幸福指数:466.666667 |
| 工号为:sales001的员工的幸福指数:2500.000000 |
| 工号为:sales002的员工的幸福指数:885.714286 |
| 工号为:sales003的员工的幸福指数:1200.000000 |
+-----------------------------------------------------------------+
9 rows in set

搜索出来的数据是正确的,没有报错。

Illegal mix of collations for operation 'concat'的更多相关文章

  1. mysql5.6修改字符编码,ERR:Illegal mix of collations for operation 'concat'

    mysql5.6修改字符编码,ERR:Illegal mix of collations for operation 'concat' 1.问题起因:搭建环境初始化mysql的时候看到mysql配置文 ...

  2. MySQL Error: Illegal mix of collations for operation 'concat'

    在使用concat连接字符串时出现错误:MySQL Error: Illegal mix of collations for operation 'concat' 原因:字段操作默认为UTF8的编码, ...

  3. Illegal mix of collations for operation 'like' while searching with Ignited-Datatables

    Stack Overflow Questions Developer Jobs Tags Users   Log In Sign Up Join Stack Overflow to learn, sh ...

  4. mysql 客户端连接报错Illegal mix of collations for operation

    服务端用的是utf-8,客户端工具打开表和视图是会报Illegal mix of collations for operation错误,经排查,可以采用以下语句解决 SET character_set ...

  5. 错误之Illegal mix of collations for operation 'like'

    内容来自博客:https://www.cnblogs.com/install/p/4417527.html MySQL Illegal mix of collations for operation ...

  6. myslq数据库用union all查询出现 #1271 - Illegal mix of collations for operation 'UNION'

    出现 #1271 - Illegal mix of collations for operation 'UNION' 的原因是两个字符编码不匹配造成的. 我遇到的是  utf8_general_ci ...

  7. mysql提示:Illegal mix of collations for operation ‘UNION’

    http://www.111cn.net/database/mysql/56096.htm show variables like "%char%"; show variables ...

  8. 有关mysql的utf8和utf8mb4,以及Illegal mix of collations for operation 'like'

    参考以下几个帖子: https://www.cnblogs.com/install/p/4417527.html https://blog.csdn.net/Yetmoon/article/detai ...

  9. Mysql Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) for operation '='

    MySQL字符串比较bug: select * from table_a a left join table_b b on a.field_a = b.field_b   error: Illegal ...

随机推荐

  1. Mxnet 查看模型params的网络结构

    import mxnet as mx import pdb def load_checkpoint(): """ Load model checkpoint from f ...

  2. (实用)使用unetbootin制作Linux的U盘启动盘

    本文介绍在Ubuntu(基于Debian的操作相同)使用unetbootin将Linux操作系统的安装镜像烧录到U盘中,使得U盘成为安装介质.当然,windows系统下也同样可以使用该软件的相应版本. ...

  3. 【苏勇老师Linux 入门笔记】网络基础

    IP 地址 IP 编制时一个双层编制方案,一个 IP 地址标示一个主机 (或一个网卡接口). 一个 IP 地址分为两个部分:网络部分(所属区域)和主机部分(标示区域中的哪个主机).IPv4 共32位, ...

  4. c# 正则实践

    Regex reg = new Regex(@"<img[\s]+src[\s]*=[\s]*['""](?<picPath>.*)['"&q ...

  5. MYSQL 分组合并函数

    From: http://blog.csdn.net/wwwyuanliang10000/article/details/27536175 MySQL中group_concat函数完整的语法如下:gr ...

  6. Ubuntu14.04下安装Libsvm,并使用Libsvm

    (1)Ubuntu14.04下安装Libsvm 转载:https://blog.csdn.net/katrinawj/article/details/78915874 一.下载: 网址:http:// ...

  7. quake3中求1/sqrt(x)的算法源代码

    quake3中求1/sqrt(x)的算法源代码如下(未作任何修改): float Q_rsqrt( float number ) { long i; float x2, y; const float ...

  8. 几个免费IP地址查询API接口

    转:http://blog.csdn.net/ishxiao/article/details/52670242 -------------------------------------------- ...

  9. Fragment管理工具类

    Fragment相关→FragmentUtils.java→Demo addFragment : 新增fragment removeFragment : 移除fragment replaceFragm ...

  10. js 按键

    原文:https://www.cnblogs.com/lunlunshiwo/p/8705856.html 上周临近周末休息的时候,一个同事跑过来了,对我说:“阿伦啊,有一个页面出问题了,火狐浏览器所 ...