Todd Davies
Todd Davies

Reputation: 5522

Android SQL query problem

I'm hitting a wall in an android SQL query, this is what I have so far:

        mDb.query(false, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_ROWONE, KEY_ROWTWO, KEY_ROWTHREE, KEY_ROWFOUR, KEY_ROWFIVE}, KEY_ROWONE +" LIKE '?%'", new String[] { letter }, null, null, null, null);

Basically, I want the query to return all the rows in the table where KEY_ROWONE starts with the variable letter (a string containing one letter).

I get a force close when I'm running the code, and I'm really puzzled.

I promise to tick the best answer!

Upvotes: 0

Views: 236

Answers (2)

Vivienne Fosh
Vivienne Fosh

Reputation: 1778

Just in case someone will be interested, here's full database tutorial for android: http://knightswhocode.com/wordpress/?p=14

Upvotes: 0

Todd Davies
Todd Davies

Reputation: 5522

It's alright guys, panic over, I found the solution:

mDb.query(true, DATABASE_TABLE, new String[] {KEY_ROWID, KEY_ROWONE, KEY_ROWTWO, KEY_ROWTHREE, KEY_ROWFOUR, KEY_ROWFIVE}, KEY_ROWONE+" LIKE ? || '%'", new String[] { l }, null, null, null, null);

Upvotes: 1

Related Questions