Home > Article > Daily Programming > How to use or in mysql
OR operator is used in MySQL to join conditions, if any condition is true, then the expression is true. The syntax is <condition1> || <condition2>, where the condition can be a Boolean expression. You can use the OR operator to query records that meet multiple conditions. It has a lower priority than the AND operator. If necessary, use parentheses.
OR operator in MySQL
1. Overview
The OR operator (||) is used in MySQL to logically connect two or more conditions. The result is as follows:
2. Syntax
The syntax of the OR operator is as follows:
<code><condition1> || <condition2></code>
where<condition1>
and <condition2>
is a Boolean expression.
3. Usage Examples
The following are some examples of using the OR operator:
<code class="sql">SELECT * FROM users WHERE name = "John" OR name = "Jane";</code>
<code class="sql">SELECT * FROM products WHERE price > 100 OR quantity > 50;</code>
<code class="sql">SELECT * FROM users WHERE role = "Admin" OR role = "Editor";</code>
4. Other notes
The above is the detailed content of How to use or in mysql. For more information, please follow other related articles on the PHP Chinese website!