Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
通过 RMySQL 连接到数据库我写了一些 R 脚本 - 使它们更容易:是否可以将 MySQL Query 中的日期设置为变量?
例如
x<-"2012-12-01" rs <- dbGetQuery(db,"**** where date between 'x' and '2012-12-31'")
是否有任何可能性或者“”中的所有内容都只是 MySQL 的东西?谢谢!
用于paste动态编写查询:
paste
x<-'2012-12-01' query <- paste("**** where date between '",x,"' and '2012-12-31'",sep='')
这将创建一个查询,如:
"**** where date between '2012-12-01' and '2012-12-31'"
然后
rs <- dbGetQuery(db,query)