Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql R:在粘贴中使用双引号,如何消除反斜杠_Sql_R_Sqlite - Fatal编程技术网

Sql R:在粘贴中使用双引号,如何消除反斜杠

Sql R:在粘贴中使用双引号,如何消除反斜杠,sql,r,sqlite,Sql,R,Sqlite,这似乎是一个老生常谈的问题,但我发现在我的案例中没有一个帖子起作用。我有一个简单的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

这似乎是一个老生常谈的问题,但我发现在我的案例中没有一个帖子起作用。我有一个简单的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\""

似乎忽略了它们。

我将您的原始SQLite查询表述为:

select *
from pred
where
    "current.time" > '2017-10-17 00:00:00' and
    "current.time" < '2017-10-17 08:00:00';

谢谢,但是考虑到我的专栏名称中有一个点,看起来我需要一个双引号。尝试使用您的示例可以得到:query@xavierpudent您需要用点转义列名是正确的。首先,你真的不应该在列名中使用点。你能试着运行我的原始查询,看看它是否有效吗?然后让我知道同样的查询在R中是否有效。它有效:)我只是不明白为什么。您将简单引号替换为双引号。它们是否具有与bash中相同的效果?@xavierpudent我所做的唯一更改是在时间戳文本周围不加双引号。正如我在回答中提到的,双引号可以解释为转义的列名。为什么不使用方括号或反勾号(SQLite中的转义符号)而不是双引号(ANSI-SQL中的通用标识符符号)?
 gsub('\\\\', '', query)
select *
from pred
where
    "current.time" > '2017-10-17 00:00:00' and
    "current.time" < '2017-10-17 08:00:00';
query <- paste0("select * from pred where \"current.time\" > '2017-10-17 00:00:00' ",
                "and \"current.time\" < '2017-10-17 08:00:00'")
query <- paste0("select * from pred where \"current.time\" between ",
                "'2017-10-17 00:00:01' and '2017-10-17 07:59:59'")