RSQLite:如何使不平等的声明?

时间:2015-01-04 14:15:32

标签: r rsqlite

我想发表以下声明:

SELECT fieldA, fieldB 
FROM tableA 
WHERE fielb != 'cond' GROUP BY fieldA.

此声明适用于 SQLite Manager ,但不适用于 RSQLite

你能帮我吗?

非常感谢:)

1 个答案:

答案 0 :(得分:2)

对我来说,!=可以正常工作。这是一个例子:

data(USArrests)
library(RSQLite)
m <- dbDriver("SQLite")
tfile <- tempfile()
con <- dbConnect(m, dbname = tfile)
dbWriteTable(con, "USArrests", USArrests)
rs <- dbSendQuery(con, "select * from USArrests where row_names != 'Alaska'")
d <- fetch(rs, n = -1)      # extract all remaining data
setdiff(row.names(USArrests), d$row_names)
# [1] "Alaska"

dbHasCompleted(rs)
dbClearResult(rs)
dbListTables(con)
dbDisconnect(con)
file.remove(tfile)