SQLite 中的 Where 子句在 android 中不起作用:( [英] Where clause in SQLite not working in android :(
本文介绍了SQLite 中的 Where 子句在 android 中不起作用:(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试在 SQLite 中查询某些数据时遇到一个烦人的错误.
I'm getting an annoying error when trying to query some data in SQLite.
这是我的代码:
Cursor cursor= db.query(TABLE_IMAGES, new String[]{"_id"}, "name" +" = "+compareToThis, null, null, null, null);
我只是将光标作为字符串返回.
I'm just returning the cursor as a string.
错误是说:
没有这样的列:compareToThis: while compiling ..... the statement
no such column: compareToThis: while compiling.....the statement
我的问题是:当它只是一个值时,为什么 SQLite 将 compareToThis 属性设置为列?
My question is: why is SQLite setting the compareToThis attribute as a column when it's just a value?
我该如何解决这个问题?
How can I fix this?
提前致谢.
推荐答案
Cursor cursor= db.query(TABLE_IMAGES, new String[]{"_id"}, "name" +" = ?", new String[]{compareToThis}, null, null, null);
选择必须包含参数占位符,下一个参数应该是参数数组.
The selection must include placeholder for parameter, and the next argument should be the array of parameters.
这篇关于SQLite 中的 Where 子句在 android 中不起作用:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文