- 我的电脑系统:Windows 10 64位
- SQL Server 软件版本: SQL Server 2014 Express
本篇博客里面使用了
scott
库,如何你现在还没有添加这个库到你的服务器里面,请在查看本篇博客前,访问这篇博文来在你的服务器里面附加scott
库。
select * from emp where sal in (1500, 3000)
select * from emp where sal in (1500, 3000, 5000)
--把sal里面是1500 和 3000 和 5000 的值都输出
上面的命令等价于:
select * from emp
where sal=1500 or sal=3000 or sal=5000
select * from emp where sal not in (1500, 3000, 5000)
上面的命令等价于:
select * from emp
where sal<>1500 and sal<>3000 and sal<>5000
--在数据库中 不等号有两种表示: != 和 <> ,推荐使用第二种
--对或(or)取反是并且(and) 对并且(and)取反是或(or)