moveToFirst does not work

427 Views Asked by At

I am using moveToFirst and it works very well. But this sql query doesnt work. I don't know why. I didn't receive any error.

My query

String sqlKomut = "SELECT SHareket.*,CHareket.[Meblag],Cari.AnlikBakiye FROM CHareket , SHareket,Cari WHERE  CHareket.[CariID]=SHareket.[CariID]=Cari.[CariID]= '"+cari.getCariID()+"' AND  SHareket.[Seri]='"+hareket.getSeri()+"' AND SHareket.[Sira]='"+hareket.getSira()+"'AND SHareket.[Tip]='"+hareket.getTip()+"' AND SHareket.[Cins]='"+hareket.getCins()+"' ORDER BY SHareket.[Satir]"; 

and I get my cursor getValue here:

Cursor cursor = db.rawQuery(sqlKomut, null);

if(cursor !=null){

    if(cursor.moveToFirst()){

        do {
            eleman.setStrEleman(cursor.getString(cursor.getColumnIndex("Seri")));
            eleman.setIntEleman1(cursor.getInt(cursor.getColumnIndex("Sira")));
            eleman.setIntEleman2(cursor.getInt(cursor.getColumnIndex("CariID")));
            eleman.setIntEleman10(cursor.getInt(cursor.getColumnIndex("Cins")));
            eleman.setIntEleman11(cursor.getInt(cursor.getColumnIndex("Tip")));
            eleman.setIntEleman11(cursor.getInt(cursor.getColumnIndex("Satir")));
            eklenenfaturalar.add(eleman);

        } while (cursor.moveToNext());
    }
}
1

There are 1 best solutions below

0
On BEST ANSWER
WHERE CHareket.[CariID]=SHareket.[CariID]=Cari.[CariID]= '...'

You cannot do multiple comparisons in a single expression like that. (The comparison returns a boolean value, 0 or 1; any more comparisons will then use this boolean instead of an ID value, e.g., you end up with something like 1=Cari.CariID.)

To use multiple comparisons, connect them with AND (as you already did with the other ones):

WHERE CHareket.[CariID]=SHareket.[CariID]
  AND SHareket.[CariID]=Cari.[CariID]
  AND Cari.[CariID]='...'
  ...