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表
这句表示的意思是 工资不大于1500 或者 可以领奖金。not (A and B) = not A or not B
谢谢你的回答,我还想问下,那如果不写成这种的,就第二个查询,写成
select * from emp where sal<=1500 and comm is null; 因该没错吧,那教材上的就与题意
不符了,是不?
离散数学的问题 呵呵
查询出工资不大于1500,并且不可以领奖金的雇员的信息
!(A&B) = !A OR !B