美文网首页
Mysql——比较运算符

Mysql——比较运算符

作者: _hider | 来源:发表于2020-04-01 22:43 被阅读0次
    • [not] between...and... [不] 在范围之内。
    • [not] in() [不] 在列出值范围内。
    • is [not] null [不] 为空。
    1.[not] between...and...

    [不] 在范围之内。

    mysql> select 1 between 15 and 20;
    +---------------------+
    | 1 between 15 and 20 |
    +---------------------+
    |                   0 |
    +---------------------+
    
    mysql> select 15 between 15 and 20;
    +----------------------+
    | 15 between 15 and 20 |
    +----------------------+
    |                    1 |
    +----------------------+
    
    mysql> select 16 not between 15 and 20;
    +--------------------------+
    | 16 not between 15 and 20 |
    +--------------------------+
    |                        0 |
    +--------------------------+
    
    2.[not] in()

    [不] 在列出值范围内。

    mysql> select 15 in (5,10,15,20);
    +--------------------+
    | 15 in (5,10,15,20) |
    +--------------------+
    |                  1 |
    +--------------------+
    
    mysql> select 16 in (5,10,15,20);
    +--------------------+
    | 16 in (5,10,15,20) |
    +--------------------+
    |                  0 |
    +--------------------+
    
    mysql> select 15 not in (5,10,15,20);
    +------------------------+
    | 15 not in (5,10,15,20) |
    +------------------------+
    |                      0 |
    +------------------------+
    
    3.is [not] null

    [不] 为空。

    mysql> select null is null;
    +--------------+
    | null is null |
    +--------------+
    |            1 |
    +--------------+
    
    mysql> select '' is null;
    +------------+
    | '' is null |
    +------------+
    |          0 |
    +------------+
    
    mysql> select 0 is null;
    +-----------+
    | 0 is null |
    +-----------+
    |         0 |
    +-----------+
    
    mysql> select null is not null;
    +------------------+
    | null is not null |
    +------------------+
    |                0 |
    +------------------+
    

    相关文章

      网友评论

          本文标题:Mysql——比较运算符

          本文链接:https://www.haomeiwen.com/subject/otbzuhtx.html