• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
山城小跳
博客园    首页    新随笔    联系   管理    订阅  订阅

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)

posted @ 2022-01-07 11:17  字母一哥  阅读(8902)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3