0

There is android sqlite database with one table, im using this query for getting values :

 Cursor cursor = db.query(Table_Items, null, "type=? AND operationtype=? AND problemtype=?", new String[] { roosazi,type,problem }, null, null,KEY_Items_ID+" "+date , null); 

everything is working fine. question is: how can i get all from specific column? let me give an example: all values with type="A" and operationtype="XYZ" are needed , no matter what problemtype is! of course i can use something like this :

 Cursor cursor = db.query(Table_Items, null, "type=? AND operationtype=?", new String[] { roosazi,type }, null, null,KEY_Items_ID+" "+date , null); 

but problem is sometimes problemtype is X and sometimes its like ALL!

how can i achieve this? can i put something like * instead of problem?

thank u so much

2
  • 1
    Can u try and rewrite teh question because i didnt understand what u want/need to do Commented Jun 11, 2015 at 12:52
  • @EE66 the question is : how can i get all values on a table independent from specific column , here I'm filtering three columns : new String[] { roosazi,type,problem } how can i ignore PROBLEM without removing it from query! means , is there any special character or something to ignore the effect of PROBLEM? since sometimes i need it , sometime i don't need it! it the same story for all of these 3 columns Commented Jun 11, 2015 at 13:14

1 Answer 1

1

I understand that you want to use the same query to get sometimes with a particular problem type like X,Y or Z, and sometimes with any problem type,

If that is the case you could use the statement 'like' in your query instead of '=' in the problemtype field

Cursor cursor = db.query(Table_Items, null, "type=? AND operationtype=? AND problemtype like '?'", 

When you want to return all values just past

problem = "%"

% simbol means any characters,

When you want to return values with a particular problem use

problem = "X"

in the values array

 new String[] { roosazi,type,problem } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.