這似乎是一箇舊的重複問題,但沒有任何我發現的帖子在我的情況下工作。我有這個簡單的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