Reputation: 3
I am having problems in the next query:
This is my array of data
String[] columns = new String[]
{ KEY_ROWELEMENTID, KEY_STUDYID, KEY_ELEMENTCODE, KEY_ELEMENTNAME};
I create a cursor to this array where: The column KEY_ELEMENTCODE is equal to a varable result AND KEY_STUDYID is equal to a varable result AND
Cursor c =
ourDatabase.query(DATABASE_TABLEELEMENTS, columns, KEY_ELEMENTCODE + "=" + elementRequest
+ "AND" + KEY_STUDYID +
"=" + idStudy, null, null, null, null);
What is the problem? I have debug and all variables has the correct values
Thanks
Upvotes: 0
Views: 88
Reputation: 1625
Just try to add space before and after "AND" and write as " AND " , hope it will resolve your issue :)
Upvotes: 0
Reputation: 1670
Yes there should be space as " AND ", One more thing, if you are comparing for Integer values then use this line,
Cursor c = ourDatabase.query(DATABASE_TABLEELEMENTS, columns,
KEY_ELEMENTCODE + "=" + elementRequest
+ " AND " + KEY_STUDYID +
"=" + idStudy, null, null, null, null);
and if you are comparing string values then you should use single inverted comma as,
Cursor c = ourDatabase.query(DATABASE_TABLEELEMENTS, columns,
KEY_ELEMENTCODE + "=" +"'"+elementRequest+"'"+
+ " AND " + KEY_STUDYID +
"=" + "'"+idStudy+"'", null, null, null, null);
Let me know if it works for you...
Upvotes: 0
Reputation: 16351
Without seeing the output from
KEY_ELEMENTCODE + "=" + elementRequest + "AND" + KEY_STUDYID + "=" + idStudy
I guess that you just have to replace
"AND"
with
" AND "
Upvotes: 1