How to return a string that has a special character - BigQuery

49 Views Asked by At

I'm very new to SQL, and I've been practicing on a dataset, but I seem to have run into some trouble:

I want to pull a certain coffee processing method: "Natural/Dry". But when I go to run my query, BigQuery just tells me that "there's no data to display."

This is the query I wrote:

SELECT Processing_Method, Acidity, Total_Cup_Points
  FROM DF
  WHERE Processing_Method='Natural/Dry'

I know the "/" is part of the issue, but I'm not sure what to do to solve it. What would the solution be?

Thanks!!

1

There are 1 best solutions below

1
DN Oomsoo On BEST ANSWER

I'm able to run the query without running into any issues. Test code I ran in BigQuery below. Perhaps there aren't any Processing_Method equal to 'Natural/Dry.' You can try a wildcard search and use NORMALIZE_AND_CASEFOLD(Processing_Method) like in example 2.

WITH
  a AS (
  SELECT
    'Natural/Dry' AS Processing_Method
  UNION ALL
  SELECT
    'Test')
SELECT
  *
FROM
  a
WHERE
  Processing_Method='Natural/Dry'

WITH
  a AS (
  SELECT
    'Natural/Dry' AS Processing_Method
  UNION ALL
  SELECT
    'Test')
SELECT
  *
FROM
  a
WHERE
  NORMALIZE_AND_CASEFOLD(Processing_Method) like '%natural%dry%'