RODBC using Data.Frame in a Join on sqlQuery()

后端 未结 1 799
你的背包
你的背包 2021-01-14 13:15

Is there a way to use a data.frame in JOIN condition using sqlQuery()?

I\'m connecting to SQL server using RODBC and need to limit the inital result set against a da

相关标签:
1条回答
  • 2021-01-14 14:08

    To reference R data in a SQL query over RODBC, your options are:

    1. Read the SQL data into R then do your manipulations there
    2. Use paste or a similar command to print relevant contents of your R dataframe into your SQL query
    3. Pass the relevant part of your R dataframe into SQL first in a temporary or permanent table and then use SQL do join on it

    In the case of #2 join would not be the appropriate SQL operation however, since you're passing a string instead of a table. Try using where, in, and clauses like that which will work on a string of names in your query as opposed to a table.

    0 讨论(0)
提交回复
热议问题