标签:使用 class select arc esc varchar datetime signed 类型
mysql为我们提供了两个类型转换函数:CAST和CONVERT,现成的东西我们怎能放过?
1 BINARY[(N)] 2 CHAR[(N)] 3 DATE 4 DATETIME 5 DECIMAL 6 SIGNED [INTEGER] 7 TIME 8 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
MySQL类型转换 使用CAST将varchar转换成int类型排序
标签:使用 class select arc esc varchar datetime signed 类型
原文地址:http://www.cnblogs.com/lanxi0320/p/6547670.html