0
 args <- commandArgs(trailingOnly = TRUE)
 id = as.character(args)
 mysqlconnection = dbConnect(MySQL(), user = 'root', password = '', dbname = 'manu',host = 'localhost') 

 sql<-sprintf("select * from net where ips1=%s;",id) 
 up = dbGetQuery(mysqlconnection, sql)

I am trying to retrieve records from the table net using R. I want to retrieve the records with a specific id which is being passed as a command line argument.However i am getting an error near " ips1=%s ",saying that the SQL syntax which i used is incorrect. Any help?

0

1 Answer 1

1

Please, try to enclose the string value to compare in single quotes ':

sql <- sprintf("select * from net where ips1='%s';",id) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.