Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I escape a single quote in Presto?

Tags:

sql

presto

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?

like image 875
scottshepard Avatar asked Sep 20 '17 21:09

scottshepard


People also ask

How do you bypass a single quote?

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.

How do you escape a quotation mark?

Alternatively, you can use a backslash \ to escape the quotation marks.

How do you escape a single quote in execute immediate?

Use a Backslash Before the Quote In MySQL, you can add a backslash before the quote to escape it.

Can I use single quotes in Presto’s SQL?

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”.

Is there an escape character in Presto SQL?

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:

What is escaping a character 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:

Does Presto use a backslash for escape characters?

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:


2 Answers

The answer, provided by a_horse_with_no_name, is to use another '.

'Driver''s License'

like image 198
scottshepard Avatar answered Oct 17 '22 21:10

scottshepard


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')
like image 2
Ganesh Avatar answered Oct 17 '22 22:10

Ganesh