我在 sqlite android 中遇到了关于 LIKE 语句的问题。我用了一个小时来弄清楚,但我无法得到错误部分。有谁知道我的错误在哪里?
public Cursor getSearch(String id) {
String[] args = { id };
return (database.rawQuery("SELECT " + SQLiteHelper.product_id
+ " as _id,"
+ SQLiteHelper.productName + " ," +SQLiteHelper.productDesp
+ "," + SQLiteHelper.productQtty + ","
+SQLiteHelper.product_CategoryF+" FROM "
+ SQLiteHelper.productTable+" WHERE "
+ SQLiteHelper.productName +" LIKE 'id%'",null));
}
错误信息
bind or column index out of range: handle 0x5e3ec0
有人知道我的错误在哪里吗?
解决方案
return (database.rawQuery("SELECT " + SQLiteHelper.product_id
+ " as _id,"
+ SQLiteHelper.productName + " ," +SQLiteHelper.productDesp
+ "," + SQLiteHelper.productQtty + ","
+SQLiteHelper.product_CategoryF+" FROM "
+ SQLiteHelper.productTable+" WHERE "
+ SQLiteHelper.productName +" LIKE '"+id+"%'",null));