IN operator in BigQuery

The IN operator in BigQuery is used to filter records based on a specified list of values. It is often used in the WHERE clause to specify multiple values in a condition.

SQL Syntax

SELECT column1, column2, ...
FROM `project_name.dataset_name.table_name`
WHERE column_name [NOT] IN (value1, value2, ...);    

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:

IN operator in BigQuery

Let’s find the employees whose Department is in Computer and Electronics.

SQL

SELECT *
FROM `ashishcoder.Coding_Dataset.employees`
WHERE Department IN ("Computer", "Electronics");    

The output of the above query is shown below:

IN operator in BigQuery