In Oracle, or is a logical operator, which means "or". It is used to filter specified conditions. When one of the conditions before and after the or operator is true, the returned result is true. If the conditions before and after or are all false, the or operator returns false.
The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.
The OR operator is a logical operator that combines Boolean expressions and returns true if one of the expressions is true.
The following explains the syntax of the OR operator:
expression_1 AND expression_2
The following table shows the results of the OR operator between true, false and NULL values.
We often use the OR operator in the WHERE clause of SELECT, DELETE and UPDATE statements to form conditions for filtering data.
If you use multiple logical operators in a statement, Oracle evaluates the OR operator after evaluating the NOT and AND operators. However, you can use parentheses to change the order of evaluation.
We will use the orders table in the sample database for demonstration. The table structure is shown in the figure below -
Example of Oracle OR operator combining two Boolean expressions
The following example finds the status as pending (Pending) Or canceled (Canceled) orders, refer to the following query statement:
SELECT order_id, customer_id, status, TO_CHAR(order_date, 'YYYY-MM-DD') AS order_date FROM orders WHERE status = 'Pending' OR status = 'Canceled' ORDER BY order_date DESC;
In this example, the statement returns all orders that satisfy one of the following expressions: status = 'Pending'
- - Or
status = 'Canceled'
Execute the above code to get the following results:
Recommended tutorial: " Oracle tutorial》
The above is the detailed content of What is the usage of or in oracle. For more information, please follow other related articles on the PHP Chinese website!