I’m writing a small application using sqlite.
The debugger says that there is a syntax error.
I’ve tried But I couldn’t find where it is.
12-20 14:13:40.353: E/SQLiteLog(2329): (1) near ",": syntax error
SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase$CursorFactory, String, String[], String, CancellationSignal) line: 1317
SQLiteDatabase.rawQuery(String, String[]) line: 1253
TemporaryDatabase.EntryGiris(int, String, int, int, int, int, int, int, int, int, int) line: 125
Here is the code:
public class TemporaryDatabase {
......
String entryGirisSQL="SELECT "+C_ID
+" FROM harcamalar WHERE "+C_YIL+"="
+yilsql+","+C_AY+"="+aysql;
Cursor cursor=ourDatabase.rawQuery(entryGirisSQL, null);
int index=cursor.getColumnIndex(C_ID);
if(index>=0)
ourDatabase.update(DB_TABLE, cv, "c_id="+index, null);
else ourDatabase.insert(DB_TABLE, null, cv);
}
}
The problem is with your SQL query.
SQL does not support commas as part of the
WHEREclause. You need to useANDandORto combine multiple expressions. Based on what you tried, I assume you want both to be satisfied. Therefore you should useAND.