函数整理

// 字符串函数
// 字符串凭借,将s1,s2....拼接
concat(s1,s2,...);

// 字符串全转小写
lower(str);

// 字符串全转大写
upper(str);

// 左填充达到n个字符串长度
lpad(str, n, pad);

// 右填充达到n个字符串长度
rpad(str, n, pad);

// 去掉字符串收尾空格
trim(str);;

// 返回字符串的部分子串,下标从1起
substring(str, start, len);

// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// 数值函数
// 向上取整
ceil(x);

// 向下取整
floor(x);

// 返回x模y
mod(x,y);

// 返回0-1内随机数
rand();

// 求参数x四舍五入,保留y位小数
round(x,y);

// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// 日期函数
// 返回当前日期,年-月-日
curdate();

// 返回当前时间,时:分:秒
curtime();

// 返回当前日期和时间,年-月-日 时:分:秒
now();

// 获取指定date的年份
year(date);

// 获取指定date的月份
month(date);

// 获取指定date的日期
day(date);

// 返回一个日期/时间值加上一个时间间隔expr后的时间值,type指的是年/月/日
date_add(date, interval expr type);

// 返回起始时间date1和结束时间date2之间的天数
datediff(date1, date2);

// ---------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
// 流程函数
// 如果value为true,则返回t,否则返回f
if(value, t, f);

// 若前面为空则返回后面,否则返回前面,注意 空串 != null
ifnull(res1, res2);

// 如果value1不为空,返回res1,...否则返回default
case when [val1] then [res1] ... else [default] end;

// 如果expr的值等于val1,返回res1,...否则返回default
case [expr] when [val1] then [res1] ... else [default] end;

posted @ 2024-12-10 19:02  一只菜狗\*-*/  阅读(51)  评论(0)    收藏  举报