Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用粘贴函数将R数据帧放入sql可用列表_R_Printf_Rodbc_Sqldf - Fatal编程技术网

使用粘贴函数将R数据帧放入sql可用列表

使用粘贴函数将R数据帧放入sql可用列表,r,printf,rodbc,sqldf,R,Printf,Rodbc,Sqldf,我在RRdataframe中有一个dataframe/列表,我想直接在RODBC查询中使用它,比如 Rdataframe= c('123456','234561','678912') a= sqlQuery(connection, "Select * from table A where A.Id in Rdataframe") 查询必须是这样的,也就是说,我不能先在R中提取表,然后再进行查找 因此,我认为它只能在以下格式中运行 a= sqlQuery(connection, "Sele

我在RRdataframe中有一个dataframe/列表,我想直接在RODBC查询中使用它,比如

Rdataframe= c('123456','234561','678912')
a= sqlQuery(connection, "Select * from table A where A.Id in Rdataframe")   
查询必须是这样的,也就是说,我不能先在R中提取表,然后再进行查找

因此,我认为它只能在以下格式中运行

a= sqlQuery(connection, "Select * from table A where A.Id in ('123456','234561','678912'))
但是,尽管sprintf&paste做了几次尝试,我还是没有成功

这是我试图尝试的,但失败了

attempt1= sqlQuery(connection, sprintf("Select * from table A where A.Id in %s", Rdataframe))

attempt2=paste(Rdataframe, sep=",")
然后在查询中使用这个trument2结构

每一个帮助都很重要

Rdataframe= c('123456' , '234561' , '678912')
df_str = paste(Rdataframe , collapse = "','" , sep=" ")
queryStr = paste("Select * from table A where A.Id in ('" ,df_str , "')" , sep="")
print(queryStr)
给出输出

[1] 从表A中选择*,其中A.Id位于“123456”、“234561”和“678912”中


你能把你的尝试产生的字符串贴出来吗?