Home > Software engineering >  '.', <column alias name>, <compound operator>, AS, BETWEEN, FROM, GROUP, IN, L
'.', <column alias name>, <compound operator>, AS, BETWEEN, FROM, GROUP, IN, L

Time:05-10

Please I need help fixing the error above _ in the title _ appeared in the first SELECT after FROM of this query, all suggestions are welcome so thank you very much.

       public ArrayList<HashMap<String, String>> getAll_Datas() {
    
        ArrayList<HashMap<String, String>> arrayListAllData = new 
        ArrayList<HashMap<String, String>>();
        SQLiteDatabase database = this.getWritableDatabase();
    
        Cursor cursor = database.rawQuery 

       (
        " SELECT lespontes.idPontes ,\n"  
        "  lespontes.Cage as Cage,\n"  
        " lespontes.Couvés,\n"  
        " dbfécondation.Fécondés "   "FROM "  
        (
                " SELECT idPontes FROM lespontes" 
                        " UNION "
                          " SELECT idPontes FROM dbfécondation" )  
        " LEFT OUTER JOIN"
          " lespontes USING (idPontes)" 
        " LEFT OUTER JOIN "
          " dbfécondation USING (idPontes)" 
        " Order By "    " lespontes.Cage "   " ASC ",null);
    
        if (cursor.moveToFirst()) {
            do {
        HashMap<String, String> hashMapData= new HashMap<String, 
        String>();
    
        hashMapData.put("idPontes", cursor.getString(0));
        hashMapData.put("Cage",cursor.getString(1));
        hashMapData.put("Couvés",cursor.getString(2));
        hashMapData.put("Fécondés", cursor.getString(3));

        arrayListAllData.add(hashMapData);
            } while (cursor.moveToNext());
        }
        return arrayListAllData;
        }
    

CodePudding user response:

Try using :-

Cursor cursor = database.rawQuery

          (
                  " SELECT lespontes.idPontes ,"  
                          "  lespontes.Cage as Cage,"  
                          " lespontes.Couvés,"  
                          " dbfécondation.Fécondés "   "FROM ("  
                                  " SELECT idPontes FROM lespontes"  
                                          " UNION "
                                            " SELECT idPontes FROM dbfécondation)"  
                          " LEFT OUTER JOIN"
                            " lespontes USING (idPontes)"  
                          " LEFT OUTER JOIN "
                            " dbfécondation USING (idPontes)"  
                          " Order By "   " lespontes.Cage "   " ASC ", null);

i.e. the parenthesises surrounding the SELECT have been embedded within the SQL. Also the useless line feeds (\n's) have also been removed.

  • Related