Why Is The ORDER BY Not Working In A Sqlite Query
Sqlite table creation in Android: // Contacts table name private static final String TABLE_CHAL = 'CD'; // Contacts Table Columns names private static final String KEY_ID = 'id';
Solution 1:
You can use
SELECT * FROM cd ORDER BY datetime(substr(date, 7, 4) || '-' || substr(date, 4, 2) || '-' || substr(date, 1, 2))
Solution 2:
I created a new column with the existing KEY_DATE
column and saved it in a yyyy-mm-ddd
format. Then I updated my query to date("+KEY_FORMAT_DATE+")";
and it worked for me.
Solution 3:
Try to replace yours with this:
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_CHAL + " ORDER BY " + KEY_DATE + "ASC", null);
Post a Comment for "Why Is The ORDER BY Not Working In A Sqlite Query"