数学函数
pi() 返回圆周率的值 例:select pi();
pow(x,y) 返回x的y次乘方 例:select pow(2,3);
ceiling(x) 返回大于x的最小整数值(向上取整) 例:select ceiling;(3.42) 等于4
floor(x) *返回小于x的最大整数值(向下取整)*例:select floor(3.83) ;等于3 字符串函数
concat (s1,s2,s3,…sn)将s1,s2,s3,…,sn连接成一个字符串 例:select concat('I','LOVE','YOU');输出为I LOVE YOU没有新的值产生
concat_ws(sep,s1,s2,…,sn)将s1,s2,…,sn连接成字符串,并用sep字符间隔 例:select concat_ws('#','hello','world');输出为hello#world 日期和时间函数 -curdate()或current_date();返回当前的日期 例:select curdate()或current_date();
dayofweek(date) *返回date所代表的是一个星期中的第几天(1-7)*例:select dayofweek('2020-10-26'); 结果为:2
dayofmonth(date)返回date是一个月的第几天 select dayofmonth('2020-10-26'); 结果为:26
dayofyear(date) 返回date是一年的第几天(1~366) 例:select dayofyear('2020-10-26'); 结果为:300
week(date) *返回date为一年中的第几周(0~53)*例如 :select week('2020-10-26'); 结果为:43
conv(‘A’,16,2)十六进制转换为2进制;conv(15,10,2); conv(15,10,8);conv(15,10,16);依次类推
聚合函数 select子句的表达式中可以包含聚合函数。
ave(all| distinct | col) 返回指定字段的平均值 例:select ave(字段) from 表名 where(查询条件)