MySQL基础学习之函数

数学函数

绝对值      abs()

圆周率      PI()

平方根  sqrt()

模除取余   mod(被除数,除数)

随机数      rand()

四舍五入    round(数字)

次方         pow(5,2)

e为底的指数函数  exp(数字)

 

字符串函数

字符长度       length(字符)

字符连接       concat(字符1,字符2)

带符号的字符连接    concat_ws('-','su','zhou')

字符插入      insert('suzhou',1,2,'yang')

字符串大写   upper(字符)

字符串小写   lower(字符)

字符串比较   strcmp(字符1,字符2)

字符串截取   substring(字符,3,4)

字符串位置    locate(字符1,字符2)

时间

年月日        curdate()

时分秒        curtime()

详细时间     now()

获得小写月份   month('2014-5-14')

获得大写月份   monthname('2014-5-15')

获得星期        dayname('2014-5-16')

一周中的某天   dayofweek('2014-5-17')

一年中的周数    week('2014-5-18')

 

 

posted @ 2014-05-16 17:37  小码农薛尧  阅读(219)  评论(0编辑  收藏  举报
薛尧的博客