mysql将字符串转换为数字类型
使用cast和CONVERT,如下:
SELECT
cast('1.00' as UNSIGNED INTEGER) as intval,
CONVERT('1.00',UNSIGNED INTEGER) as intval,
cast('1.234' as DECIMAL(4,3)) as decVal,
CONVERT('1.234',DECIMAL(4,3)) as decVal
查询结果:
111.2341.234
使用cast和CONVERT,如下:
SELECT
cast('1.00' as UNSIGNED INTEGER) as intval,
CONVERT('1.00',UNSIGNED INTEGER) as intval,
cast('1.234' as DECIMAL(4,3)) as decVal,
CONVERT('1.234',DECIMAL(4,3)) as decVal
查询结果:
111.2341.234
暂无评论。
评论功能维护中,当前仅展示历史评论。