34

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?

dennlinger
  • 9,890
  • 1
  • 42
  • 63
scottshepard
  • 781
  • 1
  • 6
  • 7

3 Answers3

44

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

'Driver''s License'

Nadjib Mami
  • 5,736
  • 9
  • 37
  • 49
scottshepard
  • 781
  • 1
  • 6
  • 7
3

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')
Ganesh
  • 486
  • 3
  • 8
  • 18
1

Use the CHR(39) character function anywhere you need a single quote. Use with either the concat function or using double pipe ||:

select count(*) as count 
from uploads
where title not in (concat('Driver', CHR(39), 's License'))

or

select count(*) as count 
from uploads
where title not in ('Driver' || CHR(39) || 's License')