mysql常用函数

between and (区间查询,前后临界值都包含,临界值不能调换位置)

select * from tablenName where columName between 10 and 89 

in关键字,查询包含关系的数据

select * from tablenName  where columName in(1,100,99)

is null和is not null 判断空值 绝不能用=null这种方式

select * from tablenName where columName is not null

求字符串长度

select length('name') 

字符串拼接

select concat(columName1,'-----',columName2)   from tablenName 

小写转换成大写

select upper('aaaaaaaaaa')  

大写转成小写

select lower('AAAAAAA')      

截取字符 substr substring 从1开始 substr=substring,以下返回’德玛’

select substr('德玛西亚之力',1,2)

查询最大

select max(columName) from tablenName 

查询最小

select min(columName) from tablenName 

四舍五入保留两位小数,以下返回0.56

select round(0.555555555555,2) 

向上取整,以下返回2

select ceil(1.00001) 

向下取整,以下返回1

select floor(1.999) 

truncate 按照保留多少位 截断数字,以下输出10.23699

select truncate(10.23699696,5)

取余数,以下两种方式都可以,都返回1

select mod(100,3);
select 100%3;

日期函数

返回当前日期加时间

select now()

返回日期不包含时间

select curDate()

返回当前时间 不包含日期

select curTIme()

if判断输出对印的值

select if(enabled,'是','否') from tablenName 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值