MySQL 字符串 转换 为数字 的几种方法
方法一:直接 加 0
select '123' + 0
方法二:函数 convert
语法:convert (value, type);
type可以为:
decimal 浮点数
signed 整数
unsigned 无符号整数
select convert('123',signed)
方法三:函数 cast
语法:cast (value as type);
type可以为:
decimal 浮点数
signed 整数
unsigned 无符号整数
select cast('123' as signed)