004 列、distinct、between、in、null

/*
时间:2020/09/07
功能:
    一 列
    二 distinct
    三 between
    四 in 
    五 null    
*/    
    

一 列

/*
select
    1 *: 全部数据
    2 列名: 
    3 别名: as ""
    4 算术运算: + - * /    
*/
select    ename as "姓名",
        sal as "月薪", 
        sal * 12 as "年薪", 
        comm as "奖金",
        sal * 12 + comm  as "全年收入"
    from emp

二 distinct

/*
distinct: 单个 多个
        (1) distinct 列名
        (2) distinct 列名 列名     
*/

三 between

-- 查询工资1500~3000之间,所有员工信息。
select * 
    from emp
    where sal >= 1500 and sal <= 3000

select * 
    from emp
    where sal between 1500 and 3000

-- 查询工资<1500或工资>3000,所有员工信息。
select * 
    from emp
    where sal < 1500 or sal > 3000

select *
    from emp
    where sal not between 1500 and 3000

四 in

-- in 单独数值
select *
    from emp
    where sal=800 or sal=1500 or sal=3000 or sal=5000

select *
    from emp
    where sal in(800, 1500, 3000, 5000)

-- in 单独数值
select *
    from emp
    where sal!=800 and sal<>1500 and sal!=3000 and sal<>5000

select *
    from emp
    where sal not in(800, 1500, 3000, 5000)

五 null

/*
null: 
    1 概念: 空值(没有值),零表示一个确定的值。 
    2 使用:
        (1) 不能参与算数运算: + - * / = <> !=
        (2) 与null算数运算结果: null 
        (3) 可以参与运算: is; not is 
        (4) 创建任何数据类型都运行: null 
*/

原文地址:https://www.cnblogs.com/huafan/p/13629659.html