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?
精彩评论