1
我是一個初學者到R和我不知道我的標題是否合適的問題,我有一個問題,從R中的SQL提取一些數據,這是代碼R數據庫提取限制問題
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 10000))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 100000))
Error in .local(conn, statement, ...) :
could not run statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1e+05' at line 1
Called from: eval(substitute(browser(skipCalls = pos), list(pos = 9 - frame)),
envir = sys.frame(frame))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000000))
Error in .local(conn, statement, ...) :
could not run statement: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1e+06' at line 1
Called from: eval(substitute(browser(skipCalls = pos), list(pos = 9 - frame)),
envir = sys.frame(frame))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 1000001))
> flights = select(paste("SELECT DISTINCT flight FROM messages ORDER BY id DESC LIMIT", 100000001))
所以這裏是我的疑問,當限制小於10000或最多4個零沒有錯誤,但約5或更多的零拋出錯誤。但如果限制以0以外的數字結束,那麼沒有錯誤,爲什麼?
而且選擇功能提前
select <- function (query, connection=con) {
return(as.data.frame(dbGetQuery(connection, query)))
}
感謝