Reputation: 3
I'am trying to get the data from SQLite database. In the begining code was like the next one and it's work just fine:
cursor = db.query("ADDITIVES",
new String[] {"ADDITIVE_ID", "ADDITIVE_NAME", "DANGER_LEVEL"},
"ADDITIVE_NAME = LIKE ?",
new String[] { "%" + nameAdditives[i] + "%" },
null, null, null);
But i need to use lowerkase on data from table before LIKE operator and I have found that this can only be made with rawQuery method. So I rewrote the code and have this one now.
cursor = db.rawQuery("SELECT ADDITIVE_ID, ADDITIVE_NAME, DANGER_LEVEL FROM ADDITIVES WHERE LOWER(ADDITIVE_ID) = LIKE ?", new String[] { "%" + eAdditives[i].toLowerCase() + "%" });
And I start getting the next error: E/SQLiteLog: (1) near "?": syntax error. What I'am doing wrong?
Upvotes: 0
Views: 1432
Reputation: 5251
You have to remove equal (=) operator:
cursor = db.rawQuery("SELECT ADDITIVE_ID, ADDITIVE_NAME, DANGER_LEVEL FROM ADDITIVES WHERE LOWER(ADDITIVE_ID) LIKE ?", new String[] { "%" + eAdditives[i].toLowerCase() + "%" });
Upvotes: 2