---
title: "mysql将字符串转换为数字类型"
author: "falseking"
date: "2017-05-24T09:58:16Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2017-05-24T09:58:16Z"
id: 2376013
url: "https://falseking.iteye.com/blog/2376013"
---

使用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