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

猜你喜欢

转载自falseking.iteye.com/blog/2376013