Why does using an Underscore character in a LIKE filter give me all the results?

后端 未结 6 1683
我在风中等你
我在风中等你 2020-11-29 00:52

I wrote the below SQL query with a LIKE condition:

SELECT * FROM Manager
WHERE managerid LIKE \'_%\'
AND managername LIKE \'%_%\'
6条回答
  •  春和景丽
    2020-11-29 01:29

    In case people are searching how to do it in BigQuery:

    • An underscore "_" matches a single character or byte.

    • You can escape "\", "_", or "%" using two backslashes. For example, "\%". If you are using raw strings, only a single backslash is required. For example, r"\%".

    WHERE mycolumn LIKE '%\\_%'
    

    Source: https://cloud.google.com/bigquery/docs/reference/standard-sql/operators

提交回复
热议问题