How to select Rows that Contain String using Query function

To select rows that contain a specific string using the QUERY function in Google Sheets, follow these steps:

  1. Identify the range of data you want to query. For example, if your data is in columns A to D and rows 1 to 100, your range would be A1:D100.
  2. Determine the string you want to search for. For example, let's say you want to select rows that contain the word "apple".
  3. Use the QUERY function with the CONTAINS operator to filter the rows based on the string. The syntax for the QUERY function is: QUERY(data, query, [headers]).

Here's an example to demonstrate how to select rows that contain the string "apple" from a range of data in columns A to D and rows 1 to 100.

Example

Assuming your data is in the range A1:D100, and you want to select rows that contain the word "apple", you can use the following formula:

=QUERY(A1:D100, "SELECT * WHERE A CONTAINS 'apple' OR B CONTAINS 'apple' OR C CONTAINS 'apple' OR D CONTAINS 'apple'")

In this formula:

This formula will return a new table with the rows that contain the word "apple" in any of the columns from A to D.

Did you find this useful?