特殊字符(')中的R where子句中

问题描述 投票:0回答:1

我是新来的R - 使用sqldf包具有特殊字符(')的问题。

df <- sqldf("select * FROM data WHERE Account in (‘I can’t validate account') ")

我无法处理(')中不能,任何人都可以请帮助?试单,双引号的各种comnbinations和\ - 没有什么作品。感谢您的帮助。

r special-characters
1个回答
1
投票

在单引号内的SQLite双单引号将被视为一个单引号:

library(sqldf)

sqldf("select 'I can''t'")
##   'I can''t'
## 1    I can't

这里是在where子句的例子:

DF <- data.frame(x = c("I", "can't"), stringsAsFactors = FALSE)
sqldf("select * from DF where x = 'can''t'")
##       x
## 1 can't
© www.soinside.com 2019 - 2024. All rights reserved.