尝试在 SQLite 中查询某些数据时遇到恼人的错误。
这是我的代码:
Cursor cursor= db.query(TABLE_IMAGES, new String[]{"_id"}, "name" +" = "+compareToThis, null, null, null, null);
我只是将光标作为字符串返回。
错误是说:
no such column: compareToThis: while compiling.....the statement
我的问题是:为什么 SQLite 将 compareToThis 属性设置为一个列,而它只是一个值?
我该如何解决这个问题?
提前致谢。
最佳答案
Cursor cursor= db.query(TABLE_IMAGES, new String[]{"_id"}, "name" +" = ?", new String[]{compareToThis}, null, null, null);
选择必须包括参数的占位符,下一个参数应该是参数数组。
关于android - SQLite 中的 Where 子句在 android :( 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4267409/