0

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

1 Answer 1

1

Try this one

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

or

paste("SELECT long,lat FROM Interpolation where var1>",Q1,sep="")
Sign up to request clarification or add additional context in comments.

3 Comments

@ George Dontas :Thanks a lot for the help it works, there was also a confused between " and ' -----> sqlStatement <- paste('SELECT long,lat FROM "Interpolation" where var1>',Q1,sep="")
@♦George Dontas :if they are two conditions Q1 et Q2 , what is the syntax?
paste("SELECT long,lat FROM Interpolation where var1>",Q1," and var2>",Q2,sep="")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.