Re: [R] Insert variable in RMySQL-Statement

2011-02-09 Thread Hugo Mildenberger
This should be much faster: idx <- c(1,2,3) res <- dbGetQuery(con,paste("select * from db where id in (",paste(idx,collapse=","),")",sep="")); print(res); On Wednesday 09 February 2011 14:13:17 Hugo Mildenberger wrote: > Arne, > > there might be faster or more elegant solutions, but

Re: [R] Insert variable in RMySQL-Statement

2011-02-09 Thread Hugo Mildenberger
Arne, there might be faster or more elegant solutions, but this is a possibility: for ( a in values ) { Temp <- dbGetQuery(con, paste("select * from db where id = ",a,sep=""))); print(Temp); } There must be also a way to make use of the "in" - operator: "select * from db wher

Re: [R] Insert variable in RMySQL-Statement

2011-02-09 Thread PtitBleu
Maybe this solution will help you. Ptit Bleu. library(DBI) library(RMySQL) drv<-dbDriver("MySQL") con<-dbConnect(drv, username=my_name, password=my_pwd, dbname=my_db, host="localhost") for (a in values) { requete<-paste("select * from db where id=",a,sep="") rs<-dbSendQuery(con, requete

[R] Insert variable in RMySQL-Statement

2011-02-09 Thread Arne H. Schulz
Dear list, I'm working with a MySQL-Table and would like to extract selected ids that are stored in a vector: Ids <- c(1,2,3) How do I insert this variable in a for loop like this: For (a in values) { Temp <- dbGetQuery(con, "select * from db Where