반응형
[Oracle SQL] SELECT 실습_ 논리연산자
I 논리연산자 (AND, OR, NOT)
▶ 연산자 우선순위 : AND > OR
1. AND, OR 비교
1) AND
SELECT DEPTNO,ENAME,JOB,SAL FROM EMP WHERE DEPTNO=20 AND SAL>2500;
2) OR
SELECT DEPTNO,ENAME,JOB,SAL FROM EMP WHERE DEPTNO=20 OR SAL>2500;
2. 연산자 우선순위
1) AND ~ OR
SELECT DEPTNO,ENAME,JOB,SAL FROM EMP WHERE DEPTNO=20 AND SAL>2500 OR JOB='CLERK';
2) OR ~ AND
SELECT DEPTNO,ENAME,JOB,SAL FROM EMP WHERE SAL>2500 OR JOB='CLERK' AND DEPTNO>=20;
3) OR ~ ( ... AND ... )
SELECT DEPTNO,ENAME,JOB,SAL FROM EMP WHERE SAL>2500 OR (JOB='CLERK' AND DEPTNO>=20);
3. NOT
1) !=
SELECT DEPTNO,ENAME,JOB,SAL FROM EMP WHERE JOB != 'CLERK';
2) NOT IN
SELECT DEPTNO,ENAME,JOB,SAL FROM EMP WHERE JOB NOT IN ('CLERK','SALESMAN');
반응형
'ORACLE SQL > 01_SELECT 실습' 카테고리의 다른 글
[Oracle SQL] SELECT 실습_ 리스트 연산자 (0) | 2019.01.01 |
---|---|
[Oracle SQL] SELECT 실습_ 범위연산자 (0) | 2019.01.01 |
[Oracle SQL] SELECT 실습_ ROWNUM (0) | 2018.12.31 |
[Oracle SQL] SELECT 실습_ DECODE, CASE (0) | 2018.12.31 |
[Oracle SQL] SELECT 실습_ DISTINCT (0) | 2018.12.31 |