OR operator in BigQuery

The OR operator in SQL is used to combine multiple conditions in a WHERE clause. If any of the conditions separated by the OR operator is true, the row is included in the result set. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.

SQL Syntax

SELECT column_name(s)
FROM `project_name.dataset_name.table_name`
WHERE condition1 OR condition2 OR condition3 ...;    

Example: Let’s have the Employees table. To view all the records, execute the following query.

SQL

SELECT * FROM `ashishcoder.Coding_Dataset.employees`;    

The output of the above query is shown below:

OR operator in BigQuery

Let’s find the employees whose Age is greater than 30 or Salary is greater than 20000.

SQL

SELECT *
FROM `ashishcoder.Coding_Dataset.employees`
WHERE Age > 30 OR Salary > 20000;    

The output of the above query is shown below:

OR operator in BigQuery