简体   繁体   中英

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

Try this one

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

or

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM