一:字符串函数:

  concat(string2 [,....])          //连接函数    select CONCAT(id,'|',name) as id_name from t1

  lcase(string2)              //转换成小写

  ucase(string2)              //转换成大写

  length(string2)              //string长度

  ltrim(string2)              //去除前端空格

  rtrim(string2)              //去除后端空格

  repeat(string2,count)          //重复count次数

  replace(str,search_str,replace_str)    //在str中用replace_str 替代search_str

  substring(str,position [,length])     //从str的position开始,取length个字符   position 从1开始

  space(count)              //生成count个空格

 

二:数学函数

  bin(decimal_number)         //十进制转二进制   SELECT BIN(255);

  ceiling(number2)           //向上取整   SELECT CEILING(10.10) ==>11

  floor(number2)            //向下取整  SELECT FLOOR(10.90)  ==> 10

  max(num1,num2)          //取最大值

  min(num1,num2)           //取最小值

  sqrt(number2)            //开平方

  rand()                //返回0-1内的随机值

  max(column)   min(column)      //取列的最大值最小值 配合聚合时使用  group by

 

三:日期函数

  curdate()              //返回当前日期

  curtime()              //返回当前时间

  now()                //返回当前日期时间

  unix_timestamp(date)        //返回当前date的unix时间戳

  from_unixtime()           //返回unix时间戳的日期值

  week(date)             //返回日期date为一年中的第几周

  year(date)              //返回日期date的年份

  datediff(expr,expr2)         //返回起始时间expr和结束时间expr2间天数

  

posted on 2016-03-04 15:47  yinmz  阅读(314)  评论(0编辑  收藏  举报