Below is my code for the query where I am currently passing the ids of only 8 products which exists in the DB table of 100 records.
String query = "SELECT productId IN (" + makePlaceholders(ids.length)+"),"+ " * FROM " + tableName + " WHERE type LIKE 'percent'"
+ " UNION ALL "
+ "SELECT productId IN (" + makePlaceholders(ids.length)+"),"+ " * FROM " + tableName + " WHERE type LIKE 'currency' ORDER BY cash DESC";
cursor = dataBase.rawQuery(query, ids);
My problem is, it showing all the records (that is all 100 records) instead of only those 8 I am passing from ID using the IN
clause. I want these 8 records (or more passed in the function) to be shown ORDER
by cash.
Now how should I write this query to achieve my goal.
Aucun commentaire:
Enregistrer un commentaire