在Swift中,我正在连接到sqlite数据库,并希望运行select语句:
sqlite3_prepare_v2(db, "select OneWord from words where OneWord='?' and definition='';", -1, &statement, nil) // Returns SQLITE_OK
但是当我尝试绑定变量时:
sqlite3_bind_text(statement, 1, "Hello", -1, nil)
它告诉我:Query prepare error: column index out of range
这在INSERT语句中很好用。我在做什么错?
最可能的原因是问号附近的引号,将查询字符串更改为
"select OneWord from words where OneWord = ? and definition = '';"
带引号的情况是查询OneWord
等于“?”的行