mysql 查看内置函数_mysql内置函数

一、字符串函数

1.concat(s1,s2....sn):把传入的参数连接成一个字符串;

2.insert(str,x,y,str):从str的x位置开始,替换y长度的字符串为str,select insert('abcdefg',2,3,'hello');

3.lower(str),upper(str):将字符串转换为大写,小写;

4.left(str,x) right(str,x) 返回str左边(右边)x个字符,x为null则返回null;

5.lpad(str,n,pad) rpad(str,n,pad)  用pad对字符串str从最左边(右边)进行填充,直到总长度达到n ; select name,lpad(name,10,'#'),rpad(name,10,'(') from cats;

6.trim(),ltrim(),rtrim()去掉两边,左边,右边空格;select concat('1',trim('   abc   '),'2'),concat('1',ltrim('   abc   '),'2'),concat ('1',rtrim('   abc   '),'2')G;

7.replace(str,a,b) 在字符串str中用字符串b替换所有的字符串a;

8.strcmp(s1,s2):如果S1比S2小,返回-1;如果S1比S2大则返回1;如果相等则返回0;

9.substring(str,x,y) 返回字符串str中从位置x起,长度为y的子字符串;

二、数值函数

abs(x):返回绝对值;

ceil(x):返回大于x的最小整数;

floor(x):返回小于x的最大整数;

mod(x,y):返回x与y的模;

rand():返回0-1之间的随机数   select round(rand()*100);

round(x,y):返回参数x的y位小数的四舍五入结果;

truncate(x,y):返回数字x截断为y位小数的结果;

三、日期函数

curdate() curtime() now();

select curdate();

select unix_timestamp(now());

select from_unixtime(1331110656);

select week(now()),year(now());

select hour(curtime()),minute(curtime());

select monthname(now());

select date_format(now(),"%Y-%m-%d %H:%i:%s");

date_add(xxx,interval x day);

data_sub(xxx,interva; x day);

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值