【发布时间】:2018-03-30 13:08:13
【问题描述】:
这似乎是一个老生常谈的问题,但我发现的所有帖子都不适用于我的情况。我有这个简单的 SQL 查询:
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 中的通用标识符符号)?