9951 explained code solutions for 126 technologies


google-big-queryHow do I use Google BigQuery LIKE statements?


Google BigQuery provides the LIKE statement to allow users to filter query results based on a pattern. The pattern is specified using wildcard characters _ and %. The _ character matches any single character, while the % character matches any sequence of characters.

For example, the following query uses the LIKE statement to find all records with a name starting with John:

SELECT *
FROM `my_table`
WHERE name LIKE 'John%'

This query will return all records from the my_table table with a name that starts with John.

The following query uses the LIKE statement to find all records with a name ending with Smith:

SELECT *
FROM `my_table`
WHERE name LIKE '%Smith'

This query will return all records from the my_table table with a name that ends with Smith.

The following query uses the LIKE statement to find all records with a name containing John:

SELECT *
FROM `my_table`
WHERE name LIKE '%John%'

This query will return all records from the my_table table with a name that contains John.

Helpful links

Edit this code on GitHub