在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. python 读写二进制文件实例

    本程序,首先写入一个矩阵到二进制文件中,然后读取二进制文件恢复到另外一个矩阵中. #coding:utf--8 #https://www.cnblogs.com/cmnz/p/6986979.html ...

  2. 如何在Windows 10安装和使用Linux的Bash shell

    转载自:百度经验 Windwos 10 的周年更新为开发人员提供一个大的新功能:一个完整的,基于Ubuntu的Bash shell中,可以直接在Windows上运行Linux软件. 这使得“Linux ...

  3. MySQL5.5.21图解教程

    大家都知道MySQL是一款中.小型关系型数据库管理系统,很具有实用性,对于我们学习很多技术都有帮助,前几天我分别装了SQL Server 2008和Oracle 10g数据库,也用了JDBC去连接他们 ...

  4. numpy的排序

  5. JDBC Statement对象执行批量处理实例

    以下是使用Statement对象的批处理的典型步骤序列 - 使用createStatement()方法创建Statement对象. 使用setAutoCommit()将自动提交设置为false. 使用 ...

  6. Ubuntu -- 安装、卸载程序的命令

    通过sudo apt-get install xxxx 安装软件后,总是无法卸载干净,这里以Apache 为例,提供方法:首先sudo apt-get remove apache2再sudo apt- ...

  7. Python——eventlet.backdoor

    eventlet.backdoor 是正在运行中的进程内的 Pyhon 交互解释器. 该模块便于检测一个长期运行进程的运行状态,提供了一种可以不阻塞应用正常操作的 Pyhon 交互解释器,从而极大地方 ...

  8. PyQt的图片资源的路径问题。

    百度到的PyQt的添加资源大部分都是通过Qt Creater添加资源的,适用于拖拽形成的界面. 问题一:纯粹手写的界面,添加资源呢? 文件夹路径: |----img |--aa.jpg |----vi ...

  9. Java Number类

    一般地,当需要使用数字的时候,我们通常使用内置数据类型,如:byte.int.long.double等. 例如: int i = 5000; float gpa = 13.65; byte mask ...

  10. 10.11 Linux网络相关 10.12 firewalld和netfilter 10.13 netfilter5表5链介绍 10.14 iptables语法

    Linux网络相关 ifocnfig 查看网卡ip(yum install net-tools) ip add 查看网卡 ip add = ifocnfig ifconfig 不显示down掉的网卡, ...