zoukankan      html  css  js  c++  java
  • mysql常见内置函数

    在mysql中有许多内置的函数,虽然功能都能在PHP代码中实现,但巧妙的应用mysql内置函数可以大大的简化开发过程,提高效率。

    在这里我总结一下一些常用的,方便以后查看:

    mysql字符串函数:

    concat(String2 [,...])         //连接字串

    lcase(string2)           //转换成小写

    ucase(string2)           //转换成大写

    length(string)           //string长度

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

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

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

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

    substring(str,position [,length])   //position开始,取length个字符,注意:position偏移量是从1开始的

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


    mysql数学函数:

    bin(decimal_number) //十进制数字转换成二进制

    ceiling(number2) //向上取整

    floor(number2) //向下取整

    max(列名) //最大值

    min(列名) //最小值

    sqrt(number) //平方根

    rand() //随机数(0-1),可以进行随机排序:select * from user order by rand();


    mysql日期函数:

    curdate() // 返回当前日期

    curtime() //返回当前时间

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

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

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

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

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

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

  • 相关阅读:
    《笨办法学python》 第14课手记
    《笨办法学Python》 第13课手记
    杭电2009----求数列的和
    杭电2008----数值统计
    杭电2007----平方和与立方和
    杭电2006----求奇数的乘积
    杭电2005----第几天?
    杭电2004---- 成绩转换
    杭电2003----求绝对值
    杭电2002----计算球体积
  • 原文地址:https://www.cnblogs.com/lxhyty/p/11276886.html
Copyright © 2011-2022 走看看