5.where_in_在指定的字段里面

USE SQLSERVER;
SELECT * FROM EMP;

--in关键字
--查询字段数据包含或不包含(数值1,...)

--查找员工编号为(7369, 7839)
    select * from emp where empno in(7369, 7839);
    --等价
        select * from emp where empno=7369 or empno=7839;

--查找员工编号不是为(7369, 7839)
    select * from emp where empno not in(7369, 7839);
    --等价于
        select * from emp where empno!=7369 and empno!=7839;
        select * from emp where empno<>7369 and empno<>7839;--推荐写法 != 等价于 <>

--查找BOOS的详细信息(多种写法)
    select * from emp where empno=7839;
    select * from emp where empno in(7839);
/*
    注意:
        字段 in(数值A,数值B,...)表示:在(not) 段 数值A 和 数值B...中字段的数据,而不是一个范围

    语法:
        select * from * where * (not) int(F1, F2, F3...);
    
    语意:
        select * from emp where sal not in(1000, 3000);
        
        来自emp中 sal 的字段数值 不是1000和3000的数值,查询出来
*/

 

posted @ 2016-07-04 13:53  Mr_Target  阅读(352)  评论(0编辑  收藏  举报