这似乎是一个旧的重复问题,但没有任何我发现的帖子在我的情况下工作。我有这个简单的SQL查询:R:双引号粘贴,如何摆脱反斜杠
min.t <- "2017-10-17 00:00:00"
max.t <- "2017-10-17 08:00:00"
query <- paste0('select * from pred where \"current.time\">\"',min.t,'\" and
\"current.time\"<\"',max.t,'\"')
"select * from pred where \"current.time\">\"2017-10-17 00:00:00\" and
\"current.time\"<\"2017-10-17 08:00:00\""
因为你可以看到反斜杠仍然是因为简单的引用。我需要保留查询的简单引号,因为列名包含一个点。如果我从膏去除齿隙,我得到了相同的结果:
paste0('select * from pred where "current.time">"',min.t,'" and
"current.time"<"',max.t,'"')
[1] "select * from pred where \"current.time\">\"2017-10-17 00:00:00\" and
\"current.time\"<\"2017-10-17 08:00:00\""
和
gsub('\\\\', '', query)
似乎忽略它们。
为什么不使用方括号或反引号(SQLite中逸出符号),而不是双引号(ANSI-SQL中的一般标识符符号)? – Parfait