PostgreSQL的逃避where子句
问题描述:
,所以我试图运行一个脚本这样一个单引号:PostgreSQL的逃避where子句
select id
from owner
where owner.name = "john's"
,我收到此错误:ERROR: column "john's" does not exist
。
而且我想是这样的:where owner.name = 'john\'s'
,但它DIT不行
任何人都知道我怎么可以运行这样一个查询?
答
当你将它们加倍时,你可以逃脱单引号。 例如:
= 'john''s'
答
试试这个
select id
from owner
where owner.name = (E'john\'s')::text
尝试双单引号= “约翰的'”? – JamieD77
[在PostgreSQL中用单引号插入文本]可能重复(http://*.com/questions/12316953/insert-text-with-single-quotes-in-postgresql) – JNevill
'e'john \'s''应该做的伎俩。 (e前缀允许在字符串文字中使用c样式反斜杠引号(以及其他内容)) – joop