I have my database query currently set up like so:
Edit, By the way my variables (_ID, CAT_ITEM and BUDGET_AMOUNT) actualy contain exactly the same text and formatting as they are written, silly i know, but anyway that shouldn’t be the problem
private String[] from = {_ID, CAT_ITEM, BUDGET_AMOUNT, };
private String orderBy = _ID + " ASC";
private String whereIn = "IN_OUT='in'";
Cursor cursor = db.query(CAT_BUD_TAB, from, whereIn, null, null, null, orderBy);
Which does exactly what i want it to do, but i wanted to try using a rawQuery instead (just to get the hang of query statements and test it out, also i wouldn’t need so many string variables).
Here’s what i came up with:
private String incomeQuery = "SELECT _ID, CAT_ITEM, BUDGET_AMOUNT FROM CAT_BUD_TAB WHERE IN_OUT=’in’";
Cursor cursor = db.rawQuery(incomeQuery, null);
However this isn’t working (I get the SQLException no such column) so i’m trying to work out what the difference is, I figure there’s just something wrong with my statement but no idea what. Can anyone offer me any advice? Thanks
From your code it looks like
_ID,CAT_ITEM,BUDGET_AMOUNTandCAT_BUD_TABare String fields. Are their values the same as the field names?Your single quotes also look different between the two queries.
Not related to your problem, but you will also need to add
ORDER BY _ID ASCto the end of the sql to replicate the result order.