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

posted @ 2021-03-12 19:53  船长博客  阅读(1362)  评论(0编辑  收藏  举报
永远相信美好的事情即将发生!