Table of Contents
Wildcard characters are special characters used in Google Sheets Query to substitute for one or more characters. The most commonly used wildcard characters include the asterisk (*), which is used to match any characters within a string, and the question mark (?), which is used to match a single character. Wildcard characters can be used in a variety of ways to create more flexible search results. For example, to find all cells with text that begins with a certain letter, you could use the asterisk wildcard followed by the letter.
You can use the % sign as a wildcard character in Google Sheets queries:
Method 1: Return Cells That Start with Certain Characters
=QUERY(A1:A10, "Select A where A like 'hello%'")
Method 2: Return Cells That End with Certain Characters
=QUERY(A1:A10, "Select A where A like '%hello'")
Method 3: Return Cells That Contain Certain Characters
=QUERY(A1:A10, "Select A where A like '%hello%'")
The following examples show how to use each method in practice.
Method 1: Return Cells That Start with Certain Characters
We can use the following formula to return every cell in column A that starts with ‘We’:
=QUERY(A1:A10, "Select A where A like 'We%'")
The following screenshot shows how to use this formula:
Method 2: Return Cells That End with Certain Characters
We can use the following formula to return every cell in column A that ends with ‘th’:
=QUERY(A1:A10, "Select A where A like '%th'")
The following screenshot shows how to use this formula:
Method 3: Return Cells That Contain Certain Characters
We can use the following formula to return every cell in column A that contains ‘ou’ somewhere within the string:
=QUERY(A1:A10, "Select A where A like '%ou%'")
The following screenshot shows how to use this formula:
The following tutorials explain how to perform other common queries in Google Sheets: