0

I have a sql database with one column of ID #'s and a another column that has the corresponding info of each ID. I have a vector that contains the ID #'s that I want the corresponding info to. How do I query only those specific ID's while also getting there corresponding information, and store it into a table?

I've tried for loops, I've tried filtering, and hard coding it.

con <- dbConnect(RSQLite::SQLite(), "data.db") 

##after connecting call all the ID's in the vector given and extract the corresponding information and store it into a table 


If I tired a for loop the table would not print all of the information, but rather only the information of the last ID in the vector, the filtering wouldn't work because it suggested that the vector only had to be of vector length one instead of 90,000. The actual results should be a table that contains only the patient ID #'s and the corresponding information of the people who I have in the vector.

nohelsss
  • 3
  • 4
  • You have the answer here https://stackoverflow.com/questions/47834160/pass-r-vector-to-sql-query – Theo Jun 11 '19 at 04:40
  • If the table in the SQL database is not to large, you can query all the table with the columns you want, store it in a data frame in R and then use the merge() or match() function to get what you want. – Alexandre georges Jun 11 '19 at 07:24

0 Answers0