SQL> select * from emp
2 where deptno = 10 and empno = 7782 or empno = 7902
3 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7782 CLARK MANAGER 7839 09/06/1981 00:00:00 2450 10
7902 FORD ANALYST 7566 03/12/1981 00:00:00 3000 20
2 rows selected.
Is this
SQL> select * from emp
2 where deptno = 10 and (empno = 7782 or empno = 7902)
3 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7782 CLARK MANAGER 7839 09/06/1981 00:00:00 2450 10
1 row selected.
or
SQL> select * from emp
2 where (deptno = 10 and empno = 7782) or empno = 7902
3 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- ------------------- ---------- ---------- ----------
7782 CLARK MANAGER 7839 09/06/1981 00:00:00 2450 10
7902 FORD ANALYST 7566 03/12/1981 00:00:00 3000 20
2 rows selected.
But of course the correct answer is:
NEVER rely on any precedence, ALWAYS use parentheses to show what you want to do and be sure this is what you do.
[Updated on: Thu, 17 August 2017 15:11]
Report message to a moderator