12.6 C
London
Wednesday, June 4, 2025
HomeSoftware TutorialsGoogle SheetsGoogle Sheets Query: How to Use WHERE IN a List

Google Sheets Query: How to Use WHERE IN a List

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

You can use the following syntax in a Google Sheets query to return all rows where a column contains a value in a list:

=QUERY(A1:C11, "SELECT * WHERE A MATCHES '(value1|value2|value3)'")

This particular query will return all rows in the range A1:C11 where the value in column A is equal to value1, value2, or value3.

Note: The | operator stands for “OR” in Google Sheets.

The following example shows how to use this syntax in practice.

Example: Use WHERE IN List in Google Sheets Query

Suppose we have the following dataset that contains information about various basketball players:

We can use the following query to return all rows where the value in the “Team” column is equal to Mavs, Magic, Kings, or Lakers:

=QUERY(A1:C11, "SELECT * WHERE A MATCHES '(Mavs|Magic|Kings|Lakers)'") 

The following screenshot shows how to use this query in practice:

Google Sheets query where in list

Notice that the only rows returned are the ones where the value in the “Team” column is equal to Mavs, Magic, Kings, or Lakers.

You can also use similar syntax to query for rows where a column contains one of several numeric values.

For example, we can use the following query to return all rows where the value in the “Points” column is equal to 19, 20, or 22:

=QUERY(A1:C11, "SELECT * WHERE C MATCHES '(19|20|22)'") 

The following screenshot shows how to use this query in practice:

Notice that the query only returns the rows where the value in the “Points” column is equal to 19, 20, or 22.

Additional Resources

The following tutorials explain how to perform other common operations in Google Sheets:

Google Sheets Query: How to Return Only Unique Rows
Google Sheets Query: How to Remove Header from Results
Google Sheets Query: How to Ignore Blank Cells in Query

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories