Home >Database >Oracle >What is the usage of or in oracle

What is the usage of or in oracle

WBOY
WBOYOriginal
2022-01-21 14:15:5113444browse

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.

What is the usage of or in oracle

The operating environment of this tutorial: Windows 10 system, Oracle 11g version, Dell G3 computer.

What is the usage of or in oracle

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.

What is the usage of or in oracle

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 -

What is the usage of or in oracle

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:

What is the usage of or in oracle

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn