• 一千行MySQL学习笔记(十)


    --// 内置函数 ----------
    -- 数值函数
    abs(x) -- 绝对值 abs(-10.9) = 10
    format(x, d) -- 格式化千分位数值 format(1234567.456, 2) = 1,234,567.46
    ceil(x) -- 向上取整 ceil(10.1) = 11
    floor(x) -- 向下取整 floor (10.1) = 10
    round(x) -- 四舍五入去整
    mod(m, n) -- m%n m mod n 求余 10%3=1
    pi() -- 获得圆周率
    pow(m, n) -- m^n
    sqrt(x) -- 算术平方根
    rand() -- 随机数
    truncate(x, d) -- 截取d位小数

    -- 时间日期函数
    now(), current_timestamp(); -- 当前日期时间
    current_date(); -- 当前日期
    current_time(); -- 当前时间
    date('yyyy-mm-dd hh:ii:ss'); -- 获取日期部分
    time('yyyy-mm-dd hh:ii:ss'); -- 获取时间部分
    date_format('yyyy-mm-dd hh:ii:ss', '%d %y %a %d %m %b %j'); -- 格式化时间
    unix_timestamp(); -- 获得unix时间戳
    from_unixtime(); -- 从时间戳获得时间

    -- 字符串函数
    length(string) -- string长度,字节
    char_length(string) -- string的字符个数
    substring(str, position [,length]) -- 从str的position开始,取length个字符
    replace(str ,search_str ,replace_str) -- 在str中用replace_str替换search_str
    instr(string ,substring) -- 返回substring首次在string中出现的位置
    concat(string [,...]) -- 连接字串
    charset(str) -- 返回字串字符集
    lcase(string) -- 转换成小写
    left(string, length) -- 从string2中的左边起取length个字符
    load_file(file_name) -- 从文件读取内容
    locate(substring, string [,start_position]) -- 同instr,但可指定开始位置
    lpad(string, length, pad) -- 重复用pad加在string开头,直到字串长度为length
    ltrim(string) -- 去除前端空格
    repeat(string, count) -- 重复count次
    rpad(string, length, pad) --在str后用pad补充,直到长度为length
    rtrim(string) -- 去除后端空格
    strcmp(string1 ,string2) -- 逐字符比较两字串大小

    -- 流程函数
    case when [condition] then result [when [condition] then result ...] [else result] end 多分支
    if(expr1,expr2,expr3) 双分支。

    -- 聚合函数
    count()
    sum();
    max();
    min();
    avg();
    group_concat()

    -- 其他常用函数
    md5();
    default();

    (未完待续) 
    
    

              (作者:Shocker 来源:http://www.cnblogs.com/shockerli/p/1000-plus-line-mysql-notes.html)

  • 相关阅读:
    面向对象的软件测试技术
    软件质量与软件测试
    测试方法
    测试计划的编写
    Monkey环境配置
    简单非线性关系数据集测试
    支持向量机
    最邻近规则分类
    Django1.9开发博客(14)- 集成Xadmin
    决策树
  • 原文地址:https://www.cnblogs.com/Grace7582/p/4743632.html
Copyright © 2020-2023  润新知