From This post and This post, I got a way to write an rsqlite dynamic command. However, it doesn't work for me. My data looks like:
Id <- c(34, 22, 86)
sqlcmd <- paste("select col1, col2 from DB where ItemId =", Id, sep="")
Df <- dbGetQuery(conn, sqlcmd)
My sqlcmd
gives me a list of strings as
"select col1, col2 from DB where STOREID =34"
"select col1, col2 from DB where STOREID =22"
"select col1, col2 from DB where STOREID =86"
However, when I pass sqlcmd
to dbGetQuery
, it only returns data with ItemId = 34
, which is the first element in the Id
list.
I'm wondering if anyone has any ideas on why does this happen? Any help would be appreciated!