无法为SELECT命令绑定sqlite语句

问题描述 投票:0回答:1

在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语句中很好用。我在做什么错?

swift sqlite bind
1个回答
0
投票

最可能的原因是问号附近的引号,将查询字符串更改为

"select OneWord from words where OneWord = ? and definition = '';"

带引号的情况是查询OneWord等于“?”的行

© www.soinside.com 2019 - 2024. All rights reserved.