I am new to R and mySQL and would like to run the following mysql command in R
query = "select x, y from table where z in ('a', 'b');" sqlQuery(connection, query)
Suppose I have a very long variable length vector. Is it possible to do
vector = c('a','b', .....) query = "select x, y from table where z in **vector**;"
I tried
query = paste("select x, y from table where z in (", paste(vector, collapse =', '), ");")
but I lose the quotes in brackets and get
query = "select x, y from table where z in (a, b);"
which does not start in sqlQuery. Is there a way to use the paste command to get a string of strings? Or is there a better way to do what I would like to accomplish?
source share