Mysql中类型转换函数Cast()的用法
Cast(字段名 as 转换的类型),其中类型可以为:
BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL[(M[,D])]
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]
用法:
SELECT CAST(ctime AS char) as new FROM user;
ctime是原列名, new是新列名
参考:
https://stackoverflow.com/questions/12126991/cast-from-varchar-to-int-mysql