Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I escape double and single quotes in google sheets query?

I have this query in google sheets cell:

=QUERY(Sheet1!A2:F, "SELECT * WHERE A='te'xt"text'", 0)

I can escape double quote like this: text""text

But how can I escape double and single quote? te'xt"text

like image 930
Дмитрий Миронов Avatar asked Dec 01 '25 13:12

Дмитрий Миронов


1 Answers

One possible alternative would be to do some pre-processing (before the query)

=ArrayFormula(QUERY({regexmatch(Sheet1!A2:A, "te\'xt"&char(34)&"text"),Sheet1!A2:F}, "Select Col2, Col3, Col4, Col5, Col6,Col7  where Col1 = true", 0))

The regex match will return 'true' for all rows matching the pattern. Then the query() selects only the rows with 'true' in Col1.

like image 198
JPV Avatar answered Dec 05 '25 13:12

JPV



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!