• 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 模块特点
    python 对象类型有哪些?
    python 异常处理
    python urllib2查询数据
    哈希表之词频统计
    泛型 队列
    大小端存储
    收藏 去掉 html 标签的perl 小函数
    好玩 多线程 显示
    服务器客户端 之 文件下载
  • 原文地址:https://www.cnblogs.com/lxhyty/p/11276886.html
Copyright © 2020-2023  润新知