Mysql点滴-MYSQL字符数字转换
来源:互联网 发布:国家税务局网络发票 编辑:程序博客网 时间:2024/05/22 01:50
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)
二进制,同带binary前缀的效果 : BINARY
字符型,可带参数 : CHAR()
日期 : DATE
时间: TIME
日期时间型 : DATETIME
浮点数 : DECIMAL
整数 : SIGNED
无符号整数 : UNSIGNED
附录2
http://dev.mysql.com/doc/refman/5.0/en/cast-functions.htmlmysql转换函数之cast
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>-> 2
If you use a number in string context, the number automatically is converted to a
-> 'hello you 2'
MySQL supports arithmetic with both signed and unsigned 64-bit values. If you are using numeric operators (such as
-> 18446744073709551615
mysql>
-> -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,
-> -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,
- Mysql点滴-MYSQL字符数字转换
- MYSQL字符数字转换
- MYSQL字符数字转换
- mysql 数字字符转换成数字整
- 深入MYSQL字符数字转换的详解-
- mysql 将 字符 转换成 数字
- Mysql 数字、字符函数
- Mysql 数字类型转换
- mysql日期字符转换
- mysql 数据库字符转换
- mysql字符大小写转换
- mysql 点滴
- mysql点滴
- mysql点滴
- 【转】用MYSQL都可能会遇到的问题:MYSQL字符数字转换
- MySQL#数字转字符、MySQL字符串拼接
- mysql 字符转换,cast,concat 字符转换
- mysql 字符串数字间转换
- jQuery 学习笔记(一)——jQuery简介、jQuery语法
- 深入研究线程池
- Oracle实体类模板
- Java多线程wait/notify
- cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *
- Mysql点滴-MYSQL字符数字转换
- GEF property view的使用
- ARM的NEON技术
- PHP创建验证码
- VC释放资源
- 在java程序设计中,vector与hashtable用法的区别,请详细说明。
- Android给bitmap图加上倒影效果
- Android 通过Intent 传递对象
- 命令模式