How can I escape a '
(single quote) in Presto?
This is where I am trying to use it
select count(*) as count
from uploads
where title not in ('Driver's License')
I've tried the usual escapes: , 'Driver\'s License'
, "Driver's License"
, E'Driver\'s License'
but nothing seems to work. Presto's docs are vague. Anyone know?
Single quotes tell Integration Engine to take what is enclosed in the single quotes literally. No escaping is used with single quotes. Use a double backslash as the escape character for backslash.
Alternatively, you can use a backslash \ to escape the quotation marks.
Use a Backslash Before the Quote In MySQL, you can add a backslash before the quote to escape it.
Presto’s SQL needs no escape character; instead it uses a double character notation. Here’s a simple example of what I mean: What if I want single quotes to actually appear in the result? I need to do this in Presto: I have simply used two single quotes to tell the interpreter the places where “I really want to include a single quote”.
Some SQL dialects use a backslash as the escape character. Presto’s SQL needs no escape character; instead it uses a double character notation. Here’s a simple example of what I mean: What if I want single quotes to actually appear in the result? I need to do this in Presto:
This is called escaping a character. Some SQL dialects use a backslash as the escape character. Presto’s SQL needs no escape character; instead it uses a double character notation. Here’s a simple example of what I mean: What if I want single quotes to actually appear in the result? I need to do this in Presto:
Some SQL dialects use a backslash as the escape character. Presto’s SQL needs no escape character; instead it uses a double character notation. Here’s a simple example of what I mean:
The answer, provided by a_horse_with_no_name, is to use another '
.
'Driver''s License'
Put a single quotes two times in place of single quotes, which you need to escape:
select count(*) as count
from uploads
where title not in ('Driver''s License')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With