日期:2014-05-16 浏览次数:20781 次
比如:`server_id` varchar(2) NOT NULL default '',
手动转化类型:
select server_id from cardserver where game_id = 1 order by server_id+0 desc limit
使用MySQL函数CAST/CONVERT:
select server_id from cardserver where game_id = 1 order by CAST(server_id as SIGNED) desc limit 10;
select server_id from cardserver where game_id = 1 order by CONVERT(server_id,SIGNED) desc limit 10;
cast跟convert的用法如下 signed 后面还有个INTEGER?? 可以不写的
用CAST函数或者CONVERT
CAST(expr?? AS?? type),?? CONVERT(expr,type)?? ,?? CONVERT(expr?? USING?? transcoding_name)?
CAST()?? 和CONVERT()?? 函数可用来获取一个类型的值,并产生另一个类型的值。?
这个类型?? 可以是以下值其中的?? 一个:???
BINARY[(N)]?
CHAR[(N)]?
DATE?
DATETIME?
DECIMAL?
SIGNED?? [INTEGER]?
TIME?
UNSIGNED?? [INTEGER]