zoukankan      html  css  js  c++  java
  • Mysql使用小tips

    一。.常用函数

    1.IFNULL(expr1,expr2)         
    如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2。IFNULL()返回一个数字或字符串值,取决于它被使用的上下文环境。

    举例如下:

    mysql> select IFNULL(1,0);     
                         -> 1     
    mysql> select IFNULL(0,10);     
                         -> 0     
    mysql> select IFNULL(1/0,10);     
                         -> 10     
    mysql> select IFNULL(1/0,yes);     

    2. IF(expr, v1, v2)
    如果expr成立,返回值为v1,否则返回v2

    mysql> select if(1>2,2,3),
        -> if(1<2,'yes','no'),
        -> if(strcmp('test','test1'),'no','yes');
    +-------------+--------------------+---------------------------------------+
    | if(1>2,2,3) | if(1<2,'yes','no') | if(strcmp('test','test1'),'no','yes') |
    +-------------+--------------------+---------------------------------------+
    |           3 | yes                | no                                    |
    +-------------+--------------------+---------------------------------------+
    1 row in set (0.00 sec)

    3.java中怎么给Mysql传参
    String QUERY_SQL = "select plat_id,appkey,income from external_dataexternal_api_data where dayid='"+DateUtils.str2Date(target_time)+"'";


  • 相关阅读:
    Zookeeper数据类型
    Zookeeper基本命令
    Redis集群
    Mysql 模拟自增主键
    git回滚版本操作
    Redis缓存穿透和雪崩
    日期格式jackson格式化
    Zookeeper安装
    redis主从复制
    Redis哨兵模式
  • 原文地址:https://www.cnblogs.com/LHWorldBlog/p/7810159.html
Copyright © 2011-2022 走看看