我对R和mySQL都不熟悉,想在R中运行以下mysql命令:
假设我有一个非常长的变量长度向量。 是否可以执行该操作?
query = "select x, y from table where z in ('a', 'b');"
sqlQuery(connection, query)
假设我有一个非常长的变量长度向量。 是否可以执行该操作?
vector = c('a','b', .....)
query = "select x, y from table where z in **vector**;"
我尝试过
query = paste("select x, y from table where z in (", paste(vector, collapse =', '), ");")
但是我在括号里失去了引号,得到的结果是
query = "select x, y from table where z in (a, b);"
在sqlQuery中无法运行。有没有办法使用粘贴命令来获取字符串?或者有更好的方法来实现我的目标吗?
type
参数),建议使用不同的引号类型。在我的 Linux Box 中,我可以访问所有参数(我可以使用 type = "cmd")。我没有 Windows 机器来检查,但这很奇怪。 - dickoashQuote
的代码。你会看到一个特定的检查,用于在 Windows 上设置type
参数(如果它缺失)。当然,你可以通过type
强制使用特定的引用样式,但这应该是明确的。 - Hong Ooi