Reputation: 1150
I have a table like this:
Char1 Char2 Difficulty
--------------------------------------------------
jon sara 1
pablo victor 2
laura patricia 1
marta juanjo 3
marina goku 4
I want to select all the rows where difficulty = 1 and difficulty = 2. I have tried to do:
"SELECT * FROM " + table + " WHERE " + DatabaseOpenHelper.COLUMN_DIFFICULTY + " LIKE '1%'" + " AND " + DatabaseOpenHelper.COLUMN_DIFFICULTY + " LIKE '2%'"
But it's not working, I am new to SQLite so I will appreciate any explanation with the answer. Thanks!
Upvotes: 1
Views: 272
Reputation: 152797
There are multiple problems:
You did not actually describe your problem beyond "it's not working".
You'd need whitespace between column names and the LIKE
keyword.
You don't need LIKE
at all. Use =1
in place of LIKE '1%'
etc.
To combine multiple conditionals, you probably want OR
in place of AND
. A single row column cannot be 1
and 2
at the same time.
Upvotes: 1