检索Android的SQLite的两个日期之间的数据日期、两个、数据、Android

由网友(帆布鞋也比你高跟鞋优雅*)分享简介:我想找回在Android中两个日期之间的数据的SQLite 我在 SQLiteAdapter 类使用的一个功能。我的功能I want to retrieve data between two dates in Android SQLite I used one function in SQLiteAdapter cl...

我想找回在Android中两个日期之间的数据的SQLite 我在 SQLiteAdapter 类使用的一个功能。我的功能

I want to retrieve data between two dates in Android SQLite I used one function in SQLiteAdapter class. My function is

public void history(String startdate,String enddate) {  
   Cursor mCursor = db.rawQuery("SELECT * FROM "+ KK_AIRLINEBOOK + 
                    " WHERE " + KEY_Bookingdate + 
                    " BETWEEN " + startdate + " AND " + enddate , null);        
}

但它不工作就说明附近语法错误

推荐答案

将文字

public void history(String startdate,String enddate) {  
Cursor mCursor = db.rawQuery("SELECT * FROM "+ KK_AIRLINEBOOK + 
                " WHERE " + KEY_Bookingdate + 
                " BETWEEN '" + startdate + "' AND '" + enddate + "'", null);        
}  

然而,它是更好,如果你使用selectionArgs两个

However it is better if you use selectionArgs

public void history(String startdate,String enddate) {  
Cursor mCursor = db.rawQuery("SELECT * FROM "+ KK_AIRLINEBOOK + 
                " WHERE " + KEY_Bookingdate + 
                " BETWEEN ?  AND ?", new String[]{startdate, enddate});        
}
阅读全文

相关推荐

最新文章