zoukankan      html  css  js  c++  java
  • Day-3:过滤数据

    使用SELECT语句的WHERE子句指定搜索条件。

    在SELECT语句子中,WHERE+搜索条件(过滤条件)在(FROM子句)表名之后给出。同时使用WHERE与ORDER BY,ORDER BY放最后.

    select prod_name, prod_price
    from products
    where prod_price = 3.49;
    
    /*
    prod_name,           prod_price
    Fish bean bag toy    3.49
    Bird bean bag toy    3.49
    Rabbit bean bag toy  3.49
    */

    WHERE子句操作符

    操作符 说明
    = 等于
    <> 不等于
    != 不等于
    < 小于
    <= 小于等于
    !< 不小于
    >   大于
    >= 大于等于
    !> 不大于
    BETWEEN 在指定的两个值之间
    IS NULL 为NULL值

    检查单个值

    #价格小于10
    select prod_name, prod_price
    from products
    where prod_price < 10;
    
    /*
    prod_name, prod_price
    Fish bean bag toy    3.49
    Bird bean bag toy    3.49
    Rabbit bean bag toy    3.49
    8 inch teddy bear    5.99
    12 inch teddy bear    8.99
    Raggedy Ann    4.99
    King doll    9.49
    Queen doll    9.49
    
    */

    不匹配查询

    #不是DLL01供应商
    select vend_id, prod_name
    from products
    where prod_price <> 'DLL01';
    
    /*
    vend_id, prod_name
    DLL01    Fish bean bag toy
    DLL01    Bird bean bag toy
    DLL01    Rabbit bean bag toy
    BRS01    8 inch teddy bear
    BRS01    12 inch teddy bear
    BRS01    18 inch teddy bear
    DLL01    Raggedy Ann
    FNG01    King doll
    FNG01    Queen doll
    */

    范围查询

    在使用between时,必须指定一个最高值和一个最底值,且用and连接。查询的值包括开始和结尾值。

    #查5-10之间(包括5和10)
    select prod_name, prod_price
    from products
    where prod_price between 5 and 10;
    
    /*
    prod_name, prod_price
    8 inch teddy bear    5.99
    12 inch teddy bear    8.99
    King doll    9.49
    Queen doll    9.49
    */

    空值检查

    NULL:无值,与0空字符串、空格是不一样的。

    #查询无邮箱
    select cust_name
    from customers
    where cust_email is null;
    
    /*
    cust_name
    Kids Place
    The Toy Store
    */
  • 相关阅读:
    python网络编程--RabbitMQ
    python网络编程-同步IO和异步IO,阻塞IO和非阻塞IO
    python网络编程-SelectPollEpoll异步IO
    python网络编程--事件驱动模型
    python网络编程-协程(协程说明,greenlet,gevent)
    python网络编程--进程池
    python网络编程-进程锁
    python网络编程-进程间数据通信(Queue,Pipe ,managers)
    html之ul标签
    html之label标签
  • 原文地址:https://www.cnblogs.com/jp-mao/p/6557614.html
Copyright © 2011-2022 走看看