zoukankan      html  css  js  c++  java
  • MySQL函数

    字符函数

    时间函数

    数学函数

    其它函数

    delimiter // 改变结束符
    call sp1() 调用sp1函数

    select ifnull(salary, 0) from table1; 替换null值, 若salary的值为null则用0来替换

    date_format
    select date_format(now(),'%Y年-%m月-%d日');
    select date_format(now(),'%Y年-%M月-%D日');

    round (取小数位数,四舍五入)
    mysql> select round(8.756,1);
    | 8.8 |
    mysql> select truncate(8.756,1);
    | 8.7 |

    truncate (取小数位数)
    select truncate(3.433,1);
    select truncate(3.433,0);

    length 占的字节
    mysql> select length('中国');
    | length('中国') |
    | 6 |

    char_length 占的字符
    select char_length(password('aixocm'));
    mysql> select char_length('中国');
    | char_length('中国') |
    | 2 |

    left/right
    select left('abcsefg',4);

    ltrim 去掉左边空格
    rtrim
    trim
    select trim(' abc ') as 'ds';

    repeat
    select repeat('abc',3);

    replace
    select replace('hi tom', 'tom', 'mike');

    abs 取绝对值
    select abs(-32);

    mod
    select 10%3;
    select mod(10,3);

    rand 随机数
    select rand()*10;

    ceil 去掉小数位
    select ceil(rand()*10);

    round

    md5 加密
    select md5('aixocm');

    inet_aton IP地址换成数值
    select inet_aton('192.168.0.3');
    select * from t2 where inet_aton(prodName) > inet_aton('192.168.0.1') and inet_aton(prodName) < inet_aton('192.168.0.5');

    repeat('abc',3); 函数

    show function statusG

  • 相关阅读:
    [转]C# 动态调用 WebService
    [转]走进 LINQ 的世界
    [转]mybatis-generator 代码自动生成工具(maven方式)
    [转]Netty入门(最简单的Netty客户端/服务器程序)
    FastJson 常见问题
    初识 ElasticSearch
    Maven Gradle 区别
    IDEA 自动生成serialVersionUID
    restful 架构详解
    初识shell expect
  • 原文地址:https://www.cnblogs.com/wsl222000/p/4950399.html
Copyright © 2011-2022 走看看