2

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

1 回答 1

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

可能的原因是,您指的是没有''

于 2012-07-13T07:42:26.917 回答