oracle查询小问题,拙计死我了,想不明白
时间:2011-12-05
来源:互联网
             1.查询出工资大于1500并且可以领奖金的雇员的信息
select * from emp where comm is not null and sal > 1500;
2.查询出工资不大于1500,并且不可以领奖金的雇员的信息。
select * from emp where not (sal > 1500 and comm is not null);//(教材上这么写的)查询结果明显有大于1500的
我觉得还可以这么写
select * from emp where sal<=1500 and comm is null;
但查询结果却不一样,WHY?我错了吗,where?
我逻辑弄错了吗?
表就是ORACLE的Scott用户下的EMP表
            select * from emp where comm is not null and sal > 1500;
2.查询出工资不大于1500,并且不可以领奖金的雇员的信息。
select * from emp where not (sal > 1500 and comm is not null);//(教材上这么写的)查询结果明显有大于1500的
我觉得还可以这么写
select * from emp where sal<=1500 and comm is null;
但查询结果却不一样,WHY?我错了吗,where?
我逻辑弄错了吗?
表就是ORACLE的Scott用户下的EMP表
作者: runtime_error 发布时间: 2011-12-05
             select * from emp where not (sal > 1500 and comm is not null);
这句表示的意思是 工资不大于1500 或者 可以领奖金。
SQL code
            这句表示的意思是 工资不大于1500 或者 可以领奖金。
SQL code
not (A and B) = not A or not B
作者: jianghshun 发布时间: 2011-12-05
  引用 1 楼 jianghshun 的回复:
select * from emp where not (sal > 1500 and comm is not null);
这句表示的意思是 工资不大于1500 或者 可以领奖金。
  
SQL code
  
not (A and B) = not A or not B
select * from emp where not (sal > 1500 and comm is not null);
这句表示的意思是 工资不大于1500 或者 可以领奖金。
SQL code
not (A and B) = not A or not B
谢谢你的回答,我还想问下,那如果不写成这种的,就第二个查询,写成
select * from emp where sal<=1500 and comm is null; 因该没错吧,那教材上的就与题意
不符了,是不?
作者: runtime_error 发布时间: 2011-12-05
 相关阅读 更多  
      
    热门阅读
-  
 office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
          阅读:74
 -  
 如何安装mysql8.0
          阅读:31
 -  
 Word快速设置标题样式步骤详解
          阅读:28
 -  
 20+道必知必会的Vue面试题(附答案解析)
          阅读:37
 -  
 HTML如何制作表单
          阅读:22
 -  
 百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
          阅读:31
 -  
 ET文件格式和XLS格式文件之间如何转化?
          阅读:24
 -  
 react和vue的区别及优缺点是什么
          阅读:121
 -  
 支付宝人脸识别如何关闭?
          阅读:21
 -  
 腾讯微云怎么修改照片或视频备份路径?
          阅读:28
 















