如何在Presto中转义'
(单引号)?
这是我尝试使用它的地方
select count(*) as count
from uploads
where title not in ('Driver's License')
我已尝试过常见的逃避:'Driver\'s License'
,"Driver's License"
,E'Driver\'s License'
但似乎没有任何效果。 Presto的文档很模糊。有人知道吗?
答案 0 :(得分:7)
a_horse_with_no_name提供的答案是使用其他'
。
'Driver''s License'
答案 1 :(得分:0)
用两个引号代替单引号,你需要转义:
select count(*) as count
from uploads
where title not in ('Driver''s License')
答案 2 :(得分:0)
在需要单引号的任何地方使用CHR(39)
字符函数。与concat
函数或双管道||
一起使用:
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')