我如何逃脱presto中的 '
(单引号)?
这是我尝试使用它的地方
select count(*) as count
from uploads
where title not in ('Driver's License')
我已经尝试了通常的ESCAPES:,'Driver's License'
,"Driver's License"
,E'Driver's License'
,但似乎无效。Presto的文档很模糊。有人知道吗?
a_horse_with_no_name提供的答案是使用另一个 '
。
'Driver''s License'
将单个引号代替单引号,您需要逃脱:
select count(*) as count
from uploads
where title not in ('Driver''s License')
在需要一个引用的任何地方使用CHR(39)
字符函数。与concat
功能或使用Double Pipe ||
一起使用:
select count(*) as count
from uploads
where title not in (concat('Driver', CHR(39), 's License'))
或
select count(*) as count
from uploads
where title not in ('Driver' || CHR(39) || 's License')