MySQL OR

In MySQL the Logical operator OR returns true only if any of the expressions linked by it evaluates to true. If we are using the OR operator in the WHERE clause, then the query will return only those rows for which at least one of the condition linked by the OR Operator in the where clause evaluates to true.

MySQL OR Logical Operator Syntax

Below is the Basic Syntax of OR Logical operator in the WHERE clause of a SELECT statement:

MySQL OR Logical Operator Examples

To demonstrate the MySQL OR Clause, let us create a Player Table with sample records as depicted in the below image by executing the following script.

player-demo-table

Example 1: Get all the Players whose either State is New York or birth year is greater than 1964

Result:
mysql-or-ex1

Example 2: Get all the Players whose either State is not New York or birth year is greater than 1963

Result:
mysql-or-logical-operator-example-2

Leave a Reply

Your email address will not be published. Required fields are marked *