zoukankan      html  css  js  c++  java
  • 2.2 DQL 条件查询

    (一)语法

    select 查询列表

    from 表名

    where 筛选条件

    (二)筛选条件的分类

    (1)简单条件运算符

    > :大于

    <:小于

    =:等于

    <> :不等于(数据库中标准用法,建议使用"<>"表示不等于)

    != :不等于 (数据库中兼容的用法)

    >=:大于或等于

    <= :小于或等于

    <=>:安全等于。可作为普通运算符的“=”,也可以用于判断是否是NULL 如:where salary is NULL  可简化为    where salary <=>NULL

    (2)逻辑运算符

    && 、and:与。其中有一个为false则为false,所有为true则为true

    || 、or:或。其中有一个为true则为true,所有为false则为false

    !  、not:非。

    (3)模糊查询

    like:一般搭配通配符使用,可以判断字符型或数值型

    通配符:%任意多个字符,_任意单个字符

    例子1: select * from students where name like '周%';

    例子2: select * from students where name like '_星_';

    (4)其他比较运算

    between : 在两个值之间,包含边界。

    例子: select last_name,salary

                from employees

                where salary between 2500 and 3500;

    in : 等于值列表中的一个

    例子:select employee_id, last_name, salary, manager_id

               from employees

               where manager_id in (100,101,201);

    is null /is not null:用于判断null值

    “ is null ”  与 “ <=> ”的比较:
                            普通类型的数值      null值       可读性
              is null         ×                            √                √


             <=>             √                            √                ×

     

  • 相关阅读:
    06-tree Shaking
    05-babel-解析高级js语法+polyfill按需注入
    Symbol.iterator
    回调
    finally
    then的参数
    通过简单例子看Promise(一)
    作为Promise构造函数参数的函数
    resolved和rejected
    resolve和reject
  • 原文地址:https://www.cnblogs.com/huabro/p/12543266.html
Copyright © 2011-2022 走看看