Oracle入门学习(7)

WHERE子句(2)

逻辑运算符的使用

NOT, AND, OR 


1.IS NULL

SELECT ID, NAME, SALES_REP_ID

FROM S_CUSTOMER

WHERE SALES_REP_ID IS NULL;

 

 

如果用“=”号去匹配是否为空是错误的

SELECT ID, NAME, SALES_REP_ID

FROM S_CUSTOMER

WHERE SALES_REP_ID = NULL;

 

 

2.逻辑运算符的使用

NOT, AND, OR

 

SELECT LAST_NAME, SALARY, TITLE

FROM S_EMP

WHERE DEPT_ID = 41

AND TITLE = 'Stock Clerk';

 

 

 

SELECT LAST_NAME, SALARY, TITLE

FROM S_EMP

WHERE DEPT_ID = 41

OR TITLE = 'Stock Clerk';

 

 

 

逻辑运算符的优先级:

NOT > AND > OR

 

SELECT LAST_NAME, SALARY, DEPT_ID

FROM S_EMP

WHERE SALARY >= 1000

AND DEPT_ID = 44

OR DEPT_ID = 42;

其中:SALARY >= 1000 AND DEPT_ID = 44

DEPT_ID = 42; 是或的关系

 

SELECT LAST_NAME, SALARY, DEPT_ID

FROM S_EMP

WHERE SALARY >= 1000

AND (DEPT_ID = 44

OR DEPT_ID = 42);

 







 

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Terminator2015/article/details/52347584
文章标签: oracle 数据库
个人分类: Oracle
上一篇Class.forName()与xxx.class的区别
下一篇Oracle入门学习(8)
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭