Wednesday, February 13, 2013

WHERE Clause Evaluation


 The WHERE clause consists of one or more conditions that evaluate independently to TRUE or FALSE. If your WHERE clause consists of multiple conditions, the conditions are separated by the logical operators AND and OR. Depending on the outcome of the individual conditions and the placement of these logical operators, Oracle will assign a final value of TRUE or FALSE to each candidate row, thereby determining whether a row will be included in the final result set.
The WHERE clause consists of two conditions separated by AND. Thus, a row will only be included if both conditions evaluate to TRUE.


Intermediate result  Final result
WHERE TRUE AND TRUE TRUE
WHERE FALSE AND FALSE FALSE
WHERE FALSE AND TRUE FALSE
WHERE TRUE AND FALSE FALSE

Demonstrates the possible outcomes if our conditions had been separated by OR rather than AND.


Intermediate result  Final result
WHERE TRUE OR TRUE TRUE
WHERE FALSE OR FALSE FALSE
WHERE FALSE OR TRUE TRUE
WHERE TRUE OR FALSE TRUE

No comments:

Post a Comment