我试图在MonetDBLite 3.5.1中使用R64bit。我的问题是,我无法使用SQL命令过滤数据,如下面的示例:
dbGetQuery(DB,'select * from table1 where "var1" = "1"')我知道这个错误:
Error in .local(conn, statement, ...) :
Unable to execute statement 'select * from table1 where "var1" = "1"'.
Server says 'ParseException:SQLparser:42000!SELECT: identifier '1' unknown'.有什么想法吗?
发布于 2018-12-04 07:05:54
对于常量值,需要对数值使用单引号(')或无引号。所以在你的例子中,
dbGetQuery(DB,'select * from table1 where "var1" = 1')或
dbGetQuery(DB,'select * from table1 where "var1" = \'1\'')或
dbGetQuery(DB,"select * from table1 where \"var1\" = '1'")
应该都能用。
一般规则是,标识符(table1或var1)通常只需要与"一起引用,如果它们包含空格或大写字符,而常量(1)只有当它们是字符串时才需要与'一起引用。
https://stackoverflow.com/questions/53607056
复制相似问题