开发者

Unable to get the proper result

开发者 https://www.devze.com 2023-02-13 07:42 出处:网络
Here is my function.. public Cursor fetchAllAlarmGreaterByDate(long appDate, int appTime) { return mDb.query(ALARM_TABLE, null, ALARM_DATE + \">\" + appDate

Here is my function..

public Cursor fetchAllAlarmGreaterByDate(long appDate, int appTime) {

    return mDb.query(ALARM_TABLE, null, ALARM_DATE + ">" + appDate
            + " and " + ALARM_TIME + ">" + appTime, null, null, null,
            ALARM_DATE + " ASC" + " and " + ALARM_TIME + " ASC");

}

I am unabl开发者_如何学运维e to get result in asc on both column ALARM_DATE AND ALARM_TIME (it gives syntax error).

If I use only ALARM_DATE + " ASC" then it doesn't give any error but the problem is that it also doesn't give any result.

How to make it work properly?


Try this

public Cursor fetchAllAlarmGreaterByDate(long appDate, int appTime) {return mDb.query(ALARM_TABLE, null, ALARM_DATE + ">" + appDate  + " and " + ALARM_TIME + ">" + appTime, null, null, null,             ALARM_DATE + " ASC" + " , " + ALARM_TIME + " ASC");  } 

just replace the"AND" in your query with "," for ASC


return mDb.query(ALARM_TABLE, null, ALARM_DATE + " > " + appDate
            + " and " + ALARM_TIME + " > " + appTime, null, null, null,
            ALARM_DATE + ", " + ALARM_TIME + " ASC");

}

Try the above. This should solve the syntax error. What are the types of the ALARM_DATE and ALARM_TIME columns in your table?

0

精彩评论

暂无评论...
验证码 换一张
取 消