某些Android设备上的Android Sqlite SELECT查询错误

时间:2016-08-22 09:59:30

标签: android sqlite android-sqlite malformed

以下SQL查询在除Huawei Media Pad P17.0之外的几乎所有Android设备中都运行良好。如果有人给我一个理由,我真的很感激。

   cursor = database
                        .rawQuery("SELECT " + SQLDatabaseHelper.NENO_KATEGORIA + " , " + SQLDatabaseHelper.NENO_NGELI
                                + " , " + SQLDatabaseHelper.NENO_UELEKEZI + " , " + SQLDatabaseHelper.NENO_ENTIMOLOGIA
                                + " , " + SQLDatabaseHelper.MAANA_MAANA + " , " + SQLDatabaseHelper.NENO_WINGI + " , "
                                + SQLDatabaseHelper.NENO_UGA + " , " + SQLDatabaseHelper.NENO_METHALI + " , "
                                + SQLDatabaseHelper.NENO_MSEMO + " , " + SQLDatabaseHelper.NENO_NAHAU + " , "
                                + SQLDatabaseHelper.NENO_FULL + " , " + SQLDatabaseHelper.NENO_MNYAMBULIKO + " , "
                                + SQLDatabaseHelper.NENO_KISAWE + " , " + SQLDatabaseHelper.NENO_IMAGE + " FROM "
                                + SQLDatabaseHelper.TBL_MAANA + " , " + SQLDatabaseHelper.TBL_MANENO + " WHERE "
                                + SQLDatabaseHelper.NENO_ID + " = " + SQLDatabaseHelper.MAANA_NENO_ID + " AND "
                                + SQLDatabaseHelper.MAANA_NENO + " = ? COLLATE NOCASE", new String[] { searchNeno });

它返回的错误是;

  

格式错误的MATCH表达式:[ - searchkeyword](代码1)

当我搜索以连字符开头的单词时,发生

任何帮助都将非常赞赏

再次感谢

1 个答案:

答案 0 :(得分:0)

试试这个 -

cursor = database.rawQuery("SELECT " + SQLDatabaseHelper.NENO_KATEGORIA + " , " + SQLDatabaseHelper.NENO_NGELI
                                + " , " + SQLDatabaseHelper.NENO_UELEKEZI + " , " + SQLDatabaseHelper.NENO_ENTIMOLOGIA
                                + " , " + SQLDatabaseHelper.MAANA_MAANA + " , " + SQLDatabaseHelper.NENO_WINGI + " , "
                                + SQLDatabaseHelper.NENO_UGA + " , " + SQLDatabaseHelper.NENO_METHALI + " , "
                                + SQLDatabaseHelper.NENO_MSEMO + " , " + SQLDatabaseHelper.NENO_NAHAU + " , "
                                + SQLDatabaseHelper.NENO_FULL + " , " + SQLDatabaseHelper.NENO_MNYAMBULIKO + " , "
                                + SQLDatabaseHelper.NENO_KISAWE + " , " + SQLDatabaseHelper.NENO_IMAGE + " FROM "
                                + SQLDatabaseHelper.TBL_MAANA + " inner join " + SQLDatabaseHelper.TBL_MANENO + " ON ( "
                                + SQLDatabaseHelper.NENO_ID + " = " + SQLDatabaseHelper.MAANA_NENO_ID + " )  WHERE "
                                + SQLDatabaseHelper.MAANA_NENO + " = ' ? COLLATE NOCASE", new String[] { searchNeno+"'" });