Logical Operators
Operator
Its Function
Order of Precedence
NOT
Negates or returns the opposite value
of the conditional statement behind it.
Evaluated before both "And" and "OR"
AND
Used to Put more than one Logical
operation together.
Evaluated After NOT
But before OR
OR
Also used to put multiple
operations together.
Third in line after "NOT" and "AND"
NOT:
Not Negates the expression after it. It's like asking for one thing and getting the exact
oppsite. As you can see, we first asked for those prices greater than 3 Oracle responded
to our request correctly. Then we ran the exact query again with the NOT
preceding the test
condition. The result as you would expect is the opposite of the original.
AND:
Use AND when you need to put two conditions together. Here we got a bit elaborate but we
pulled several fields of data from three different tables where both conditions were true. We
tested the Product_id from the Product Table to see if it matched the Proc_id from the Transaction
table. Then we tested for those records whose Customer_ID from the Customer table matched the
Cust_id in the transaction table. The returned data are those fields requested in the select
clause, and where both conditions are true in the where clause.
OR:
The or operator retrieves data where one OR the other condition is true. Here we test
the customer_ID and the price of items. If either condition is true, the data is retrieved.