samedi 10 octobre 2015

How to order the result of SQLite query by input alphabet?

String sql = "SELECT * FROM " + TABLE_NAME +
                " WHERE " + ENGLISH + " LIKE ? ORDER BY " + ENGLISH + " LIMIT 100";

try {
            cursor = db.rawQuery(sql, new String[]{"%" + englishWord + "%"});

For example, in the column ENGLISH, there are "ice", "dice", "vice" etc. When I input the word "ice" in englishWord, I will get the result arranged firstly by "dice", followed by "ice" and "vice". But I would like "ice" to be on the first order because it has the exact word. How I can accomplish this?

Aucun commentaire:

Enregistrer un commentaire