zoukankan      html  css  js  c++  java
  • MYSQL谓词的使用和表达式

    in//使用IN谓词将一个值与其他几个值进行比较

    select * from users where id in(1,2,5);相当于select * from users where id=1 or id=2 or id=5;

    between//将单一值与一个范围内的值比较

    select * from users where id between 2 and 4;相当于select * from users where id>=2 and id<=4;

    like//搜索具有某些模式的字符串。通过百分号和下划线指定模式。

    exists//测试某个条件的行的存在性

    表达式>ALL//表达式大于由全查询返回的每个单值

    表达式>ANY//表达式至少大于由全查询返回的值之一

    条件表达式:

    select id,case name
    when '高某' then 'gp'
    when '曹某' then 'cw'
    when '唐某' then 'tg'
    else 'wz'
    end as nname
    from users;

    嵌套表表达式:

    select id,name,gender,birthday,address
    from(
    select id,name,gender,birthday,address from users where address='北京'
    )as newusers
    where id<3;

  • 相关阅读:
    串口应用
    状态栏颜色
    冒泡排序
    快速排序
    good软件测试博客地址
    软件测试面试题
    股票基础知识
    软件测试基本知识
    软件测试流程
    mycat实现分库分表(二)
  • 原文地址:https://www.cnblogs.com/Mr-Wenyan/p/8876500.html
Copyright © 2011-2022 走看看