JOINS [message #220203] |
Mon, 19 February 2007 07:58 |
suzane
Messages: 6 Registered: February 2007 Location: Mumbai
|
Junior Member |
|
|
I tried executing the following syntax
>select e.empno,e.ename,d.loc,d.dname from emp e,dept d where d.loc='CHICAGO' or d.dname='ACCOUNTANCY' and e.deptno=d.deptno;
The O/p was incorrect
But when I did the following
>select e.empno,e.ename,d.loc,d.dname from emp e,dept d where (d.loc='CHICAGO' or d.dname='ACCOUNTANCY') and e.deptno=d.deptno;
The O/p was correct. The only difference being parenthesis.
Can anyone explain me, the WORKFLOW of a syntax considering the above two cases. For your reference, the tables considered in the above are default tables in Oracle.
Please help me out.
Thanks & Regards,
Suzane
|
|
|
Re: JOINS [message #220205 is a reply to message #220203] |
Mon, 19 February 2007 08:06 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
Looks like you figured it out yourself. If it is not apparent which keyword prevails (or or and) use parentheses.
|
|
|
|
Re: JOINS [message #220249 is a reply to message #220203] |
Mon, 19 February 2007 19:17 |
William Robertson
Messages: 1643 Registered: August 2003 Location: London, UK
|
Senior Member |
|
|
suzane wrote on Mon, 19 February 2007 13:58 | The O/p was incorrect
|
It was correct, it just wasn't what you expected.
Similar precedence rules exist in arithmetic. Would you expect 1 + 2 * 3 to come to 9?
|
|
|