Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter table by string "starting with" in Big Query

I would like to implement in BigQuery the same function I can find in stringr (R package) - as str_starts()

I would like to filter a table for all the string rows starting with "Sport - ".

I use the expression LIKE but I am not sure it works correctly...

SELECT *
FROM table_1
WHERE string LIKE '%Sport - %'
like image 651
chopin_is_the_best Avatar asked Apr 28 '26 21:04

chopin_is_the_best


1 Answers

You can use REGEXP_CONTAINS on your where clause

SELECT * FROM table WHERE REGEXP_CONTAINS(Team,r'^Sport\s-\s')

Reference: https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#regexp_contains

like image 126
Nestor Avatar answered May 01 '26 08:05

Nestor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!