mysql数字转换中文版_MYSQL字符数字转换
1.
将字符的数字转成数字,比如'0'转成0可以直接用加法来实现
例如:将pony表中的d 进行排序,可d的定义为varchar,可以这样解决
select * from pony order by (d+0)
2.
在进行ifnull处理时,比如 ifnull(a/b,'0') 这样就会导致 a/b成了字符串,因此需要把'0'改成0,即可解决此困扰
3比较数字和varchar时,比如a=11,b="11ddddd";
则 select 11="11ddddd"相等
若绝对比较可以这样:
select binary 11 =binary "11ddddd"
=======================================附录1======================================
字符集转换 : CONVERT(xxx USING gb2312)
类型转换和SQL Server一样,就是类型参数有点点不同 : CAST(xxx AS 类型) , CONVERT(xxx,类型),类型必须用下列的类型:
可用的类型
二进制,同带binary前缀的效果 : BINARY
字符型,可带参数 : CHAR()
日期 : DATE
时间: TIME
日期时间型 : DATETIME
浮点数 : DECIMAL
整数 : SIGNED
无符号整数 : UNSIGNED
=======================================附录2===============================================
http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html
To cast a string to a numeric value in numeric context, you normally do not have to do anything other than to use the string value as though it were a number:
mysql> SELECT 1+'1';
-> 2
If you use a number in string context, the number automatically is converted to a BINARY string.
mysql> SELECT CONCAT('hello you ',2);
-> 'hello you 2'
MySQL supports arithmetic with both signed and unsigned 64-bit values. If you are using numeric operators (such as + or -) and one of the operands is an unsigned integer, the result is unsigned. You can override this by using the SIGNED and UNSIGNED cast operators to cast the operation to a signed or unsigned 64-bit integer, respectively.
mysql> SELECT CAST(1-2 AS UNSIGNED)
-> 18446744073709551615
mysql> SELECT CAST(CAST(1-2 AS UNSIGNED) AS SIGNED);
-> -1
Note that if either operand is a floating-point value, the result is a floating-point value and is not affected by the preceding rule. (In this context, DECIMAL column values are regarded as floating-point values.)
mysql> SELECT CAST(1 AS UNSIGNED) - 2.0;
-> -1.0
If you are using a string in an arithmetic operation, this is converted to a floating-point number.
If you convert a “zero” date string to a date, CONVERT() and CAST() return NULL when the NO_ZERO_DATE SQL mode is enabled. As of MySQL 5.0.4, they also produce a warning.
mysql数字转换中文版_MYSQL字符数字转换相关推荐
- mysql大小写转换函数_MySQL字母大小写转换函数UPPER(s)、UCASE(s)、LOWER(s)和LCASE(s)
UPPER(s)函数和UCASE(s)函数 UPPER(s)或UCASE(s)函数可以将字符串s中的字母字符全部转换成大写字母. 实例: 使用UPPER函数或者UCASE函数将字符串中的所有字母字符转 ...
- html标签转换字符类型,java把html标签字符转换成普通字符(反转换成html标签)
package net.jasonjiang.web; import org.junit.Test; import org.springframework.web.util.HtmlUtils; /* ...
- mysql常用转换函数_MySQL中常用转换函数介绍
Cast函数:CONVERT函数. 用法:CAST(expr AS type), CONVERT(expr,type) , CONVERT(expr USING transcoding_name). ...
- mysql 行列转换 动态_mysql 行列动态转换的实现(列联表,交叉表)
(1)动态,适用于列不确定情况 create table table_name( id int primary key, col1 char(2), col2 char(2), col3 int ); ...
- python编码转换在线_Python字符编码转换Unicode和str
## str 我们平时写的用引号括起来的字符串都是str类型的. >>> x = '哈哈' >>> x '\xb9\xfe\xb9\xfe' ### 根据上面的打印 ...
- mysql 二进制转字符串_MySql字符转义 | 学步园
在字符串中,某些序列具有特殊含义.这些序列均用反斜线('\')开始,即所谓的转义字符.MySQL识别下面的转义序列: \0 ASCII 0(NUL)字符. \' 单引号('''). \" 双 ...
- 【转】用MYSQL都可能会遇到的问题:MYSQL字符数字转换
飞鸽传书[转]用MYSQL都可能会遇到的问题:MYSQL字符数字转换 1. 将字符的数字转成数字,比如'0'转成0可以直接用加法来实现 例如:将pony表中的d 进行排序,可d的定义为varchar, ...
- mysql 将字符串转换数字类型的_MySQL 字符串类型用数字可以查出来 MySQL字符串类型会转换成数字 MySQL隐式类型转换...
一.发现问题 1.在一次MySQL查询中,某字段为 varchar 字符串类型,传入参数值为 int 数字类型,发现查询的结果和预期的不一致. 如: 某两列 name='11' , name = '1 ...
- Go语言进阶,交叉编译,数字与字符的转换,多变参数
对于编译在 Go语言零基础入门,从安装到运行代码 这篇文章里面有提到,这里详细说明下,因为在不同编译器.不同操作系统和系统架构上的编译都是有区别的,目前主流的OS就是Linux.Windows.Mac ...
最新文章
- 看过来,包邮送AirPods Pro!
- LeetCode Anagrams
- 硬件——STM32,GPIO篇
- zabbix配置外部邮件服务器进行邮件报警
- php %00,Nginx %00 null byte执行任意代码(php)漏洞
- mysql004操作表.增删改
- 实现图片打乱_疫情过后,是否打乱了你前进的脚步?面对现状,你将如何开展新的征程?...
- MyBatis的优化
- js实现鼠标放在一级菜单,下滑出二级菜单
- ECC椭圆曲线加密算法原理 | 比特币加密算法
- Android Studio 3.4功能
- Oracle 过程(Procedure)、函数(Function)、包(Package)、触发器(Trigger)
- jQuery命令汇总(转)
- Ubuntu改坏sudoers后无法使用sudo的解决办法
- ajax有哪些回调函数
- “智慧统计”平台研发
- python opencv入门 鼠标绘图(4)
- bzoj 2069 [ POI 2004 ] ZAW —— 多起点最短路 + 二进制划分
- Windows10神州网信版的远程桌面开启
- 计算机平面设计必学英语,平面设计师常用的11款英文字体打包
热门文章
- php将科学计算法得出的结果转换成原始数据
- 2016.5.57—— Remove Duplicates from Sorted List
- 使用VS2005调试ASP程序
- python入门经典例题-Python入门经典练习题
- 基于python的数据挖掘网课-利用 Python 练习数据挖掘
- python画折线图代码-python绘制简单折线图代码示例
- php和python和java-Java、PHP和Python各有什么优势 分别能做什么
- 用python绘制漂亮的图形-用Python代码绘制漂亮的生日蛋糕,python
- r语言和python-r语言和python学哪个
- python自学网站有哪些-分享干货:三个新手自学Python的网站!