MySQL类型转换
mysql为我们提供了两个类型转换函数:CAST和CONVERT,现成的东西我们怎能放过?
BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]
例子:
--使用CAST将varchar转换成int类型排序
select server_id from cardserver where game_id = 1 order by CAST(server_id as SIGNED) desc limit 10; --使用CONVERT将varchar转换成int类型排序
select server_id from cardserver where game_id = 1 order by CONVERT(server_id,SIGNED) desc limit 10
参考 http://blog.163.com/jzq_520/blog/static/119311262201171192914788/
MySQL类型转换的更多相关文章
- mysql类型转换函数convert与cast的用法
原文地址:https://blog.csdn.net/kouwoo/article/details/45535733 简单介绍下mysql数据库中用于类型转换的二个函数,convert与cast函数, ...
- mysql类型转换函数convert与cast的用法,及SQL server的区别
首先,convert函数 字符集转换 : CONVERT(xxx USING gb2312) 类型转换和SQL Server一样,不过类型参数上有不同: CAST(xxx AS 类型) ...
- MySQL 类型转换
1.问题描述 在项目中遇到要将Int类型转为Char类型,然后利用转化后的Char类型进行模糊查询. 例:合同编号在数据库中为int类型 8066 用利用 806 模糊查询出合同编号为8066数据记录 ...
- MySQL类型转换 使用CAST将varchar转换成int类型排序
--使用CAST将varchar转换成int类型排序 select distinct(zone_id) from guild_rank_info order by CAST(zone_id as SI ...
- MySQL生成模型
根据数据库表生成Model using System; using System.Collections.Generic; using System.Data; using System.Text; ...
- MySqL触发器以及常用转换函数注意事项
1,触发器(http://www.cnblogs.com/zzwlovegfj/archive/2012/07/04/2576989.html) 1.MYSQL中触发器中不能对本表进行 i ...
- Mysql字符串转换为整型
使用Convert(字段名, 类型)方法 SELECT CONVERT(filedName, UNSIGNED INTEGER) ;
- 安全测试===Mysql 注入技巧学习 MySQL注入技巧(2)
原文地址:http://websec.files.wordpress.com/2010/11/sqli2.pdf 0x00.介绍 也可以参考瞌腄龙的mysql注入科普:http://drops.woo ...
- MySQL- 常用的MySQL函数,指令等
MySQL查看版本: status: 或者 select version(); //select @@version MySQL昨天, 一周前 ,一月前 ,一年前的数据 这里主要用到了 DATE_SU ...
随机推荐
- Codeforces Testing Round #8 B. Sheldon and Ice Pieces 水题
题目链接:http://codeforces.com/problemset/problem/328/B 水题~ #include <cstdio> #include <cstdlib ...
- CodeForces 558A
Description Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coord ...
- 用vi写一个C 程序
root@IdeaPad:~# ls 1.txt 3.txt 5.txt 6.py evilxr test 2.txt 4.txt 5.txt~ e.txt evilxr.txt root@IdeaP ...
- JS中的call()方法的理解
fn.call(obj,arg1,arg2);这是call()方法的使用形式,apply()是差不多的.作用是用obj对象来替换fn中的this 举个栗子: function A(){ this.co ...
- H2 database 行相加-行列转换
create or replace view view_acceptCompanyasselect * from (select WARNIGID,max(CASEWHEN(zhtablename ...
- unity3d用鼠标拖动物体的一段代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 这是一段拖动物体的代码,比较简洁明了,对了解uni ...
- gnu-software
gnu coreutils https://www.gnu.org/software/coreutils/manual/coreutils.html#toc_Printing-text 目录列表 ht ...
- linux工具类之硬盘检测
软raidmount /dev/md0 /opt [root@localhost root]# cp /usr/share/doc/raidtools-1.00.3/ra ...
- https和http共存的nginx配置
server { listen 80; listen 443 ssl; server_name test.xx.com; ...
- ExtJs学习笔记之ComboBox组件
ComboBox组件 (1)ComboBox控件支持自动完成.远程加载.和许多其他特性. (2)ComboBox就像是传统的HTML文本 <input> 域和 <select> ...