Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL OR condition ????
Basic rules of OR condition require that ONE of the conditions must hold
true. Whereas for AND, BOTH must hold TRUE.
Now, being wise any good implementation will optimize OR and AND checking. As soon as LHS holds TRUE, OR condition processing stops. Whereas if LHS resolves to a FALSE condition, you can stop processing AND, because it will resolve to FALSE anyways.
Remember that parenthesis play a MAJOR Role here ... easiest thing you can do it substitute all alpha with numbers in your example.
Raj
-----Original Message-----
Sent: Wednesday, May 21, 2003 8:02 PM
To: Multiple recipients of list ORACLE-L
Hi All,
Please help me out with this puzzle -
An OR condition in a SQL query WHERE clause is always executed from left to right. True or False?
E.g. If I have (a = b) OR ((c=d) AND (e=f) AND (g=h) AND (i=k)) then first (a=b) will be checked (always) and if it returns false then only it will go to the right side of the OR condition.
AND If I have ((c=d) AND (e=f) AND (g=h) AND (i=k)) OR (a = b) then first ((c=d) AND (e=f) AND (g=h) AND (i=k)) will be checked (always) and if it returns false then only it will go to the right side of OR condition.
TIA,
Rajesh
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Pillai, Rajesh
INET: Rajesh.Pillai_at_nordstrom.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
--
Please see the official ORACLE-L FAQ: http://www.orafaq.net
--
Author: Jamadagni, Rajendra
INET: Rajendra.Jamadagni_at_espn.com
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).