Home  >  Article  >  Database  >  Mysql 数字类型转换函数

Mysql 数字类型转换函数

WBOY
WBOYOriginal
2016-06-07 18:01:29938browse

Mysql 数字类型转换函数,有此需要的朋友可以参考下用法。

1、将Int 转为varchar经常用 concat函数,比如concat(8,'0') 得到字符串 '80'
2、将varchar 转为Int 用 cast(a as signed) a为varchar类型的字符串
总结:类型转换和SQL Server一样,就是类型参数有点点不同 : CAST(xxx AS 类型) , CONVERT(xxx,类型)
可用的类型 
二进制,同带binary前缀的效果 : BINARY
字符型,可带参数 : CHAR()
日期 : DATE
时间: TIME
日期时间型 : DATETIME
浮点数 : DECIMAL
整数 : SIGNED
无符号整数 : UNSIGNED
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn