Cursor cursor = db.rawQuery("SELECT id,lastname,status FROM people WHERE " + "id = "+ IncomingiD +" FROM people WHERE status =100 ); ",null);
I want to access to “status=100 and id=incomingid” of my people table. I wrote above snipped code but I am getting an error below…. What is wrong with that query ? Could you please help me ?
E/Error(996): Error while openining peopleandroid.database.sqlite.SQLiteException: near "FROM": syntax error: , while compiling: SELECT id,lastname,status FROM people WHERE id = 1 FROM places WHERE status =100 );
You have the
FROM peoplepart twice in your query :Also, note that you have
wheretwice in your query — the two condition should be separated by andand, and not a secondwhere.Oh, and it also seems that you have a closing
)at the end of your query?Basically, your query looks like this :
But it should be looking like that :
In the end, I’m guessing your Java code should look a bit like this :