user26480
user26480

Reputation: 387

Pass numeric variable to a sql statement in R

I can't pass my variable Q1 in a SQL query in R: code:

Q1=23
sqlStatement <- paste("SELECT long,lat FROM "Interpolation" where var1>",Q1,'"',sep=""))

inter1<-dbGetQuery(con, sqlStatement;)

Erreur:

Error: unexpected symbol in "sqlStatement <- paste("SELECT long,lat FROM "Interpolation"

Can someone help me please !

Ps:I tried a lot of suggestions that I found on the forum but nothing works -How to use a variable name in a SQL statement? -Pass R variable to a sql statement

Upvotes: 0

Views: 353

Answers (1)

Yorgos
Yorgos

Reputation: 30445

Try this one

paste("SELECT long,lat FROM 'Interpolation' where var1>",Q1,sep="")

or

paste("SELECT long,lat FROM Interpolation where var1>",Q1,sep="")

Upvotes: 1

Related Questions