MySQL casting from decimal to string(mysql decimal 转 varchar)
今天群里一个哥们问我mysql怎么将decimal转成varchar,经过查阅资料发现,mysql好像不能将decimal直接转换成varchar,但是可以转成char,原文链接:http://stackoverflow.com/questions/5114959/mysql-casting-from-decimal-to-string
类似于这样的:
SELECT CAST(SUM(decimal_name) AS CHAR(50)) FROM article,注意关于mysql的sum函数返回值:
The SUM() and AVG() functions return a DECIMAL value for exact-value arguments (integer or DECIMAL),
and a DOUBLE value for approximate-value arguments (FLOAT or DOUBLE). (Before MySQL 5.0.3, SUM() and AVG() return DOUBLE for all numeric arguments.)
也就是说在5.0.3之前返回值都是double,而在之后如果sum(integer)或者sum(decimal)返回的是decimal,当sum(float) or sum(boudle)时返回的是double。
MySQL casting from decimal to string(mysql decimal 转 varchar)的更多相关文章
- [原][openstack-pike][controller node][issue-2][glance] Could not parse rfc1738 URL from string 'mysql+pymysql=http://glance:glance@controller/glance'
问题点 在手动上传镜像的时候:出现错误 Could not parse rfc1738 URL from string 'mysql+pymysql=http://glance:glance@cont ...
- Linux MySQl 5.7.17 MySQL ERROR 1366(HY000):Incorrect string value 解决方法
MySQL ERROR 1366(HY000):Incorrect string value,在往数据库中插入中文的时候会出现. 这也就是编码问题,网上大部分都是说设置下配置文件中的设置,而可悲的是在 ...
- mysql导入数据库出现:Incorrect string value: '\xE7\x82\xB9\xE9\x92\x9F' for column 'chinese' at row 1
mysql导入数据库出现:Incorrect string value: '\xE7\x82\xB9\xE9\x92\x9F' for column 'chinese' at row 1 使用 sho ...
- mysql General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'dianpumiaoshu' at row 1 解决方法
mysql General error: 1366 Incorrect string value: '\xF0\x9F\x91\x8D\xF0\x9F...' for column 'dianpumi ...
- PDO 查询mysql返回字段int变为String型解决方法
PDO 查询mysql返回字段int变为String型解决方法使用PDO查询mysql数据库时,执行prepare,execute后,返回的字段数据全都变为字符型. 例如id在数据库中是Int的,查询 ...
- Excel连接到MySQL,将Excel数据导入MySql,MySQL for Excel,,
Excel连接到MySQL 即使当今时代我们拥有了类似微软水晶报表之类的强大报表工具和其他一些灵活的客户管 理应用工具,众多企业在分析诸如销售统计和收入信息的时候,微软的Excel依然是最常用的工具. ...
- MySql命令,吐血整理的Mysql,实话,真的吐血
MySql命令,吐血整理的Mysql,实话,真的吐血 1.基本操作 2.数据库操作 3.表的操作 4.数据操作 5.字符集编码 6.数据类型(列类型) 7.列属性(列约束) 8.建表规范 9.SELE ...
- MySQL必知必会笔记-Mysql基本操作
Mysql基本操作 mysql的基本操作包括增.删.改.查,本书中前三章简单的介绍MySQL为何物,查是mysql中非常重要的功能,4-6章展示了mysql的查(查询--select)的简单实现,my ...
- mysql 字符串转数据丢失精度,mysql转换丢失精度,mysql CAST 丢失精度
mysql 字符串转数据丢失精度,mysql转换丢失精度,mysql CAST 丢失精度 =============================== ©Copyright 蕃薯耀 2017年9月1 ...
随机推荐
- docker 安装kafka
1.下载镜像这里使用了wurstmeister/kafka和wurstmeister/zookeeper这两个版本的镜像 docker pull wurstmeister/zookeeperdocke ...
- 「LibreOJ Round #9」CommonAnts 的调和数
题解: 对于subtask3:可以把相同的归在一起就是$nlogn$的了 对于subtask4: 可以使用高维前缀和的技术,具体的就是把每个质因数看作一维空间 那么时间复杂度是$\sum \limit ...
- James Munkres Topology: Lemma 21.2 The sequence lemma
Lemma 21.2 (The sequence lemma) Let \(X\) be a topological space; let \(A \subset X\). If there is a ...
- 2、Linux常用功能
防火墙的基本用法 - 启动: systemctl start firewalld - 关闭: systemctl stop firewalld - 查看状态: systemctl status fir ...
- disconf使用小结
disconf使用小结 目前我们公司用的分布式配置中心是disconf,对于普通的spring项目集成还是比较方便,主要功能点分布式配置还有配置的动态更新通知 安装disconf服务端 参考地址htt ...
- using eclipse to write c programe 0
参考:http://developer.51cto.com/art/200906/126363.htm http://www.cnblogs.com/feisky/archive/2010/03/21 ...
- 【nuget】PackageReference
.net 爬虫 <PackageReference Include="HtmlAgilityPack" Version="1.9.0" /> < ...
- SpringBoot使用ELK日志收集
本文介绍SpringBoot应用配合ELK进行日志收集. 1.有关ELK 1.1 简介 在之前写过一篇文章介绍ELK日志收集方案,感兴趣的可以去看一看,点击这里-----> <ELK日志分 ...
- KaliLinuxNetHunter教程刷入第三方Recovery与开始刷机
KaliLinuxNetHunter教程刷入第三方Recovery与开始刷机 2.刷入第三方Recovery(即TWRP) TWRP(TeamWin Recovery Project)是一款XDA大神 ...
- buils tool是什么?为什么使用build tool?java主流的build tool
定义: build tool是可以自动由源代码创建可执行的应用程序的程序. Building 包括编译.链接和打包代码成一个可用的或可执行形式. 在小型项目,开发人员常常会手动调用构建过程.在更大的项 ...