mysql集成函数_mysql内置函数

一:字符串函数:

concat(string2 [,....])          //连接函数    select CONCAT(id,'|',name) as id_name from t1

lcase(string2)              //转换成小写

ucase(string2)              //转换成大写

length(string2)              //string长度

ltrim(string2)              //去除前端空格

rtrim(string2)              //去除后端空格

repeat(string2,count)          //重复count次数

replace(str,search_str,replace_str)    //在str中用replace_str 替代search_str

substring(str,position [,length])     //从str的position开始,取length个字符   position 从1开始

space(count)              //生成count个空格

二:数学函数

bin(decimal_number)         //十进制转二进制   SELECT BIN(255);

ceiling(number2)           //向上取整   SELECT CEILING(10.10) ==>11

floor(number2)            //向下取整  SELECT FLOOR(10.90)  ==> 10

max(num1,num2)          //取最大值

min(num1,num2)           //取最小值

sqrt(number2)            //开平方

rand()                //返回0-1内的随机值

max(column)   min(column)      //取列的最大值最小值 配合聚合时使用  group by

三:日期函数

curdate()              //返回当前日期

curtime()              //返回当前时间

now()                //返回当前日期时间

unix_timestamp(date)        //返回当前date的unix时间戳

from_unixtime()           //返回unix时间戳的日期值

week(date)             //返回日期date为一年中的第几周

year(date)              //返回日期date的年份

datediff(expr,expr2)         //返回起始时间expr和结束时间expr2间天数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值