I am working with sqlite query where I am selecting multiple records from Database Table by passing ids to the db table. Now I want when I select the records they should be ORDERED. But its not ordering, below is my query please tell me where I am doing the wrong.
"SELECT * FROM tbl_product WHERE productId IN (" + makePlaceholders(ids.length)+")"+ " ORDER BY rating DESC";
It only returns the records match with the given ids but they are not in order.
And here is my makePlaceholders
method
public String makePlaceholders(int len){
if(len > 0){
StringBuilder nameBuilder = new StringBuilder();
for(int i = 0; i < len; i++){
nameBuilder.append("?").append(",");
}
nameBuilder.deleteCharAt(nameBuilder.length() - 1);
return nameBuilder.toString();
} else{
return null;
}
}
Aucun commentaire:
Enregistrer un commentaire