I have variable that contains some numbers
x1
6589
11482
13573
Another variable x2 contains
x2
110426
163684
169555
I am trying to pass these values as a variable in my sql statement in R . So far I am good if I pass one variable (x1 or x2)
id = paste((df$x1),collapse = ",")
id1= paste0("(", id, ")")
id1
example <- sqlQuery(myDB,"SELECT * FROM dbo.my_table WHERE COLUMN1 in", id1)
Not sure how to do this with two variables x1 and x2
example <- sqlQuery(myDB,"SELECT * FROM dbo.my_table
WHERE COLUMN1 in", id1"
AND COLUMN2 in", id2" ) ?????
Any help is appreciated.
Aucun commentaire:
Enregistrer un commentaire