Blogger Information
Blog 18
fans 0
comment 0
visits 16092
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
MySQL 字符串转换为数字的方法小结
Original
1386 people have browsed it

方法一:直接 加 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)

补充:下面看下mysql 字符串转数字的三种方式
方式一:+0

方式二:cast(‘字符串’ as 数值类型)

  数值类型,可以分为三种:

  整数 : SIGNED

  无符号整数 : UNSIGNED

  浮点数 : DECIMAL

方式三:convert(‘字符串’, 数值类型)

  数值类型,同样可以分为三种:

  整数 : SIGNED

 无符号整数 : UNSIGNED

 浮点数 : DECIMAL

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post