Home » SQL & PL/SQL » SQL & PL/SQL » JOINS
icon5.gif  JOINS [message #220203] Mon, 19 February 2007 07:58 Go to next message
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 Go to previous messageGo to next message
Frank
Messages: 7880
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 #220209 is a reply to message #220205] Mon, 19 February 2007 08:22 Go to previous messageGo to next message
pmaupoil
Messages: 40
Registered: February 2007
Location: France
Member
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/conditions2a.htm#1034173
Re: JOINS [message #220249 is a reply to message #220203] Mon, 19 February 2007 19:17 Go to previous message
William Robertson
Messages: 1640
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?
Previous Topic: Handling duplicate values
Next Topic: Hi i am a newbie
Goto Forum:
  


Current Time: Thu Dec 08 06:02:14 CST 2016

Total time taken to generate the page: 0.12796 seconds