wayne's space

Novice's Attitude
数据加载中……
MySQL常用函数
函数                     用法                                                   返回结果
(操作字符函数)
concat()          concat(t1,t2,...)                                  由t1,t2拼接而成的新字符串。
concat_ws()    concat_ws(s,t1,t2,...)                          由t1st2s拼接而成新字符串。
length()          length(s)                                            字符串s的长度。
left()              left(s,x)                                              字符串s最左边的x个字符。
right()            right(s,y)                                            与上面函数相对应。
trim()             trim(s)                                                去掉字符串s首尾的空格。
upper()          upper(s)                                             大写。
lower()           lower(s)                                              小写。
replace()        replace(s,t1,t2)                                    将字符串s中的t1替换为t2。
substring()    substring(s,n,m)                                截取s的字串,从第n个开始,取m个字符,n从1开始。

(操作数字函数)
abs()            abs(n)                                                n的绝对值。
ceiling()         ceiling(n)                                            不小于n的整数。
floor()           floor(n)                                              n取整。
format()        format(n,m)                                       格式化n,精度为m,每三位用逗号隔开。
mod()           mod(n,m)                                           n对m取模:n%m。
pow()           pow(n,m)                                            n的m次方。
rand()          rand()                                                 从0到1.0的随机数。
round()        round(n,m)                                 4舍5入(原文:n rounded to m decimal places)。
sqrt()          sqrt(n)                                                对n开根。  


(操作日期函数)
date()            date(dt)                                      一个日期的值。
hour()           hour(dt)                                      获取小时。
minute()        minute(dt)                                   获取分钟数。
second()        second(dt)                                  获取秒钟数。
dayname()      dayname(dt)                               星期几。
dayofmonth()  dayofmonth(dt)                          日期号。
monthname()  monthname(dt)                          月份名。
month()          month(dt)                                 月份号。
year()             year(dt)                                     年份。
curdate()         curdate()                                   当前日期。
curtime()         curtime()                                   当前时间。
now()              now()                                       当前date。
unix_timestamp()   unix_timestamp(dt)             UNIX时间戳。
utc_timestamp()    utc_timestamp(dt)               UTC时间戳。

posted on 2011-12-06 15:18 wayne woo 阅读(381) 评论(0)  编辑  收藏 所属分类: Database


只有注册用户登录后才能发表评论。


网站导航: