我在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);

最佳答案

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);

可能是因为,您引用的字符串没有''

10-08 16:44