我在android中使用sqlite,我通过传递多个where子句获取结果,这给了我一个错误。 单个where子句对我来说工作正常问题是多个where子句。 建议我做出改变或找出我正在做的错误
带有查询的错误消息
ERROR/AndroidRuntime(837): Caused by: android.database.sqlite.SQLiteException:
no such column: Maharashtra:,while compiling: SELECT _id, r_shop FROM retailer
WHERE r_state = Maharashtra AND r_city = Thane AND r_region = Checknaka
String selection = MySQLiteHelper.STATE + " = Maharashtra"
+" AND " + MySQLiteHelper.CITY + " = Thane"
+" AND " + MySQLiteHelper.REGION + " = Checknaka";
Cursor cursor = database.query(MySQLiteHelper.RETAILER_TABLE,
new String[] {MySQLiteHelper.COLUMN_ID, MySQLiteHelper.SHOP }, selection,
null, null, null, null);
答案 0 :(得分:10)
String selection = MySQLiteHelper.STATE + " = 'Maharashtra'"
+" AND " + MySQLiteHelper.CITY + " = 'Thane'"
+" AND " + MySQLiteHelper.REGION + " = 'Checknaka'";
Cursor cursor = database.query(MySQLiteHelper.RETAILER_TABLE,
new String[] {MySQLiteHelper.COLUMN_ID, MySQLiteHelper.SHOP }, selection,
null, null, null, null);
可能原因是,你指的是没有''