MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB - OR Operator



The MariaDB OR Operator is used to combine multiple conditions in a WHERE clause of MariaDB statement. It displays a record if any the conditions separated by OR operator is true.

Syntax

The syntax for using OR operator in MariaDB is given below:

SELECT column1, column2, column3, ...
FROM table_name
WHERE condition1 OR condition2 OR condtion3 ....;

Example:

Consider a database containing table called Employee with the following records:

EmpIDNameCityAgeSalary
1JohnLondon253000
2MarryNew York242750
3JoParis272800
4KimAmsterdam303100
5RameshNew Delhi283000
6HuangBeijing282800

  • To select all records of the Employee table where Salary is greater than 2800 or Age is less than 25, the query is given below.

    SELECT * FROM Employee
    WHERE Salary > 2800 OR Age < 25;
    

    This will produce the result as shown below:

    EmpIDNameCityAgeSalary
    1JohnLondon253000
    2MarryNew York242750
    4KimAmsterdam303100
    5RameshNew Delhi283000

❮ MariaDB - Operators