android sqlite如何按时间排序

时间:2012-10-19 12:17:30

标签: android sql sqlite

  

可能重复:
  How do i order my SQLITE database in descending order, for an android app?

我有下表,我想选择表的内容,但是按C_TAG_SCAN_TIME字段DESC排序。

public static final String C_ID = BaseColumns._ID; // special for id internally in system
    public static final String C_TYPE = "type";
    public static final String C_COMPANY_ID = "companyid";
    public static final String C_PERSON_ID = "person";
    public static final String C_NAME = "name";
    public static final String C_TAG_ID = "tagid";
    public static final String C_STATUS = "status";
    public static final String C_TAG_SCAN_TIME = "tagscantime";
    public static final String C_TAG_SENTSERVER_TIME = "tagsentservertime";
    public static final String C_TRANSACTIONS_LATITUDE = "transactionslatitude";
    public static final String C_TRANSACTIONS_LONGITUDE = "transactionslongitude";

这是我从表TRANSACTIONS中选择所有内容的查询。

return db.query(DBHelper.TABLETRANSACTIONS, null, null, null, null, null, null);

我的问题是如何将查询更改为在C_TAG_SCAN_TIME列上降序排序?

1 个答案:

答案 0 :(得分:8)

请试试这个......

return db.query(DBHelper.TABLETRANSACTIONS, null, null, null, null, null, C_TAG_SCAN_TIME + " DESC");